Laravel – Livewire V3 Force Update of Input
Sometimes in Livewire v3, certain input fields (e.g. select) do not update when the model is changed. To resolve this you can add a wire:key to the input with specific…
Sometimes in Livewire v3, certain input fields (e.g. select) do not update when the model is changed. To resolve this you can add a wire:key to the input with specific…
Sometimes a test fails certain times but passes another. If you want to run a test multiple times you can use the following one line bash script: for i in…
Sometimes you want to use the HTML output from a blade component in a PHP class. You can do this using the view('component')->render() method. For example: Let's say we had…
If you want to execute code from a trait when using php artisan tinker, you can do so in one of two methods. 1] Instantiate the class using the trait…
In Laravel, you can create a model with all the "batteries included" using the command: php artisan make:model Author -cfmsr Where the following makes a Controller, Factory, Migration, Seeder, Resource…
If you want to log all SQL queries to the laravel.log file use the following code in your AppServiceProvider.php - boot() method: class AppServiceProvider extends ServiceProvider { // ... public…
Laravel offers several ways to check the performance of an eloquent query. 1] Using DB query log You can log the SQL queries and get the performance of individual queries…
As highlighted by Povilas Korop (@PovilasKorop) on Twitter: in Laravel, you can call a static "saved" function on your model to forget the cached values with a specific key. Let's…
In a tweet by Tom Herrmann (@devgummibeer) (https://gummibeer.dev/), he discussed how using syncWithoutDetaching() call can kill a database. Basically, instead of doing: $user->identifiers()->syncWithoutDetaching($identifiers); Do this: DB::table('identifier_user')->having()->insertOrIgnore( $identifiers->map(fn (Identifier $identifier) =>…