Skip to content
Advertisement

Tag: laravel

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row in Laravel9

I have an integrity constraint violation when I run the php artisan db:seed command in Laravel 9. Error PDOException::(“SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (hunger-db.restaurants, CONSTRAINT restaurants_user_id_foreign FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE)”) setup_users_table setum_restaurants_table User Model Restaurant Model Answer I see some things to change

Failed Login with Tymon JWT Auth Laravel 8

When I try to get token with login function I get this error TypeError: Argument 1 passed to TymonJWTAuthJWTGuard::login() must be an instance of TymonJWTAuthContractsJWTSubject, instance of AppModelsUser given, called in …vendortymonjwt-authsrcJWTGuard.php on line 127 in file …vendortymonjwt-authsrcJWTGuard.php on line 140 Here my login function: Here my User model: How to solve my issue? Answer You must implement TymonJWTAuthContractsJWTSubject contract

laravel write multiple where clause to filter files

I don’t know how to filter this in my laravel 9 app using eloquent. I am having a files table and file_metadata (pivot) – where files has multiple metas: ex: file_metadata for 3 files: So files 5 ,6 ,7 have 2 metas (3 active, 6 signed). File 7 is active but not signed. How to write the where clause to

Laravel vapor “This action is unauthorized” with file upload

I have set up Laravel Vapor with my RESTFull app using Sanctum and now I’m trying to simply upload a file. I’m making a request POST /vapor/signed-storage-url and I’m getting: I have created the UserPolicy as described in the docs: But I keep getting This action is unauthorized. Answer The key piece of information here is that I’m using Sanctum

Get Laravel route with optional parameter

I was wondering if it’s possible to get the full url/path in Laravel with a optional parameter in it. In web.php I have this: And want to get the full url/path with this: But only ‘var1’ appears. How come? In the manual there are no examples. Answer The parameters should be in an array like:

Advertisement