Skip to content

Tag: laravel

Refactor database schema on migration

This is my initial migration Now, the easy time ended and now I have to move name and phone to customer table. This is my create customer migration. I don’t know where to do this operation so I just throw all in the migration. And alter order migration Now I’m stuck with empty customer_id. I have …

Eloquent Relationships hasMany use loop

I have a database with multiple address records of a user. When I do “pluck()” and “join()” in the foreach path, I get results. But when I type $user->getAddress->address in structures like hasOne, I get the result I want. In short, can I return the loop in hasMany more practical…

Return custom array in json model with Lumen

With Lumen 8 I have : Model : Store Controller : StoreController Repository : StoreRepository I can get my Store without any problem and get the json below : I would like to get open/close time of the Store. In my model I have a array (for test) and I can show it like that : And get this result

Foreach does not return all values

I have a foreach but it only returns the last value and not all the values, what is the problem? my array My code: Currently it only returns the last value I need you to return the following (example) If it is not clear I will try to improve it Answer If we consider your data won’t change, and you