Skip to content
Advertisement

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 no clue what to

Error 401 after successful login to Laravel using jwt

In my Laravel project, I use jwt for user authentication.I successfully login and receive the token. I send the token with the Barear prefix in the header but I get a 401 error.Meanwhile, my project works well on localhost, but it has this problem on cpanel hosts.My codes are below in config/auth.php and in configjwt.php ]; my web route: my

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 practically? Following my code: user Table adress Table UserModel Controller Answer

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

Laravel 8 – Listen to eloquent events made during a specific request

Currently, I’m trying to wire a telemetry library (OpenTelemetry php lib) to the Laravel event model. The idea is to forward traces to a third party service. A single trace consistents of a request and all database calls that have been made during the request. I’ve created three middleware components: BeforeRequest: starts a trace OnRequest: call event listener which listened

Advertisement