Skip to content

Tag: laravel

Race condition with multiple updates PHP & MySQL

I have a table called cards, Each user can create/have multiple cards. One of the cards must be set as default. Sometimes when a user performs multiple requests to set another card as default at the same time, In the end, There are two or more default cards. Initial table: id user_id is_default 1 50 0 2 50 1 …

Split assoc array by keys

I have data like this: I want to separate it into 3 different arrays like so: For the life of me i just cant seem to wrap my head around this today, I have tried doing loops and while/if using “array_colum()” but I cant get to add a 0 for the entry that does not have a matching date. PS:

Laravel translations

can someone tell me how can I search (with livewire) products which have a translatable title? Currently, I am using astrotomic/laravel-translatable package. Translations are working just fine and I can statically pull the right data but when I try to search it I have an issue because the package is expecting…

Call to a member function store() on null Laravel 8

When I click on save to update the data on my edit page, I get the following error. call to a member function store() on null Answer As a result of $request->file(‘file’) is returning null, and you are trying to call a method on null, resulting in the exception. Due to the way Laravel handles P…

Change image with and js

I have a small slider that switches the preview image to the main image. It works fine now blade.php js But I still have a picture mobile_image, and I want the mobile_image to change instead of main_image at the maximum size of 576px, for this I use <picture> I change my code to like this But my slider …