Run npm install -D prettier prettier-plugin-antlers prettier-plugin-blade prettier-plugin-tailwindcss
in your terminal
Create a .prettierrc
file with the following content
{
"singleQuote": true,
"printWidth": 140,
<?php | |
namespace App\Helper; | |
trait WpTrait | |
{ | |
/** | |
* Replaces double line-breaks with paragraph elements. |
<?php | |
trait EnhancedEnum | |
{ | |
/** | |
* Get the enum value from the name. e.g case INVOICE = 'invoice'; will return 'invoice' | |
* | |
* @param string $name | |
* @return static | |
*/ |
<?php | |
namespace App\Http\Livewire; | |
use App\Models\Event; | |
use Livewire\Component; | |
use Illuminate\Support\Str; | |
use Illuminate\Support\Carbon; | |
use Illuminate\Support\Facades\Cache; |
Here is a quick way to add authentication logging to Laravel. | |
1. Modify app/Providers/EventServiceProvider.php and add lines 16 through 32 of the example file in this GIST. | |
2. Create a new file app/Listeners/LogActivity.php and copy the contents of the file below into that file. | |
3. Enjoy logging. |
<?php | |
use PhpCsFixer\Config; | |
use PhpCsFixer\Finder; | |
$rules = [ | |
'array_syntax' => ['syntax' => 'short'], | |
'no_unused_imports' => true, | |
'blank_line_after_namespace' => true, |
<?php | |
/* | |
A simple PHP class to perform basic operations against Amazon S3 and compatible | |
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules. | |
Copyright 2022 Marco Arment. Released under the MIT license: | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights |
<?php | |
// needs picqer/php-barcode-generator | |
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); | |
$barcode = $generator->getBarcode($data, $generator::TYPE_CODE_128, 3, 100, [0,0,0]); | |
// ensure the char count is even for CODE_128_C | |
$barcodeData = (strlen($data) % 2) === 0 ? $data : '0' . $data; | |
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); |
// Core assets | |
let coreAssets = []; | |
// On install, cache core assets | |
self.addEventListener('install', function (event) { | |
// Cache core assets | |
event.waitUntil(caches.open('app').then(function (cache) { | |
for (let asset of coreAssets) { | |
cache.add(new Request(asset)); |
<?php | |
Auth::provider('sanctum:token', function ($app, $config) { | |
return new SanctumTokenUserProvider($app['hash'], $config['model']); | |
}); |