Category : laravel

i’m getting the following error when trying to filter a query by ID: My query: $film=film::wherehas(‘actor’, function($q) use($actor_id){ $q->where(‘actor_id’,’=’, $actor_id); })->get(); model Film: class film extends Model{ protected $table = "film"; protected $primaryKey = ‘film_id’; public $timestamps = false; use HasFactory; protected $sql=[‘film_id’, ‘title’, ‘length’]; } Sourc..

Read more

My database has below structure public function up() { Schema::create(‘users’, function (Blueprint $table) { $table->id(); $table->string(‘name’); $table->string(’email’)->unique()->nullable(); $table->string(‘phone’)->unique()->nullable(); $table->timestamp(’email_verified_at’)->nullable(); $table->timestamp(‘phone_verified_at’)->nullable(); $table->string(‘password’); $table->rememberToken(); $table->timestamps(); }); DB::statement(‘ALTER TABLE users ADD CONSTRAINT chk_phone_or_email CHECK (email IS NOT NULL OR email IS NOT NULL);’); } Basically I have two fields phone and email that can be null but both ..

Read more

I have one to many relation in my project ( the user has many details ), and when i delete any user row it says SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`sehhatys_saudi`.`details`, CONSTRAINT `details_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)) (SQL: delete from `users` ..

Read more

The api I built wqith apssport and laravel 8 does not logout by default. I found a script, but it does not remove the entries in the oauth-access-tokens table I afdded a function to the AuthController: public function logout(Request $request){ $accessToken = auth()->user()->token(); $token= $request->user()->tokens->find($accessToken); $token->revoke(); return response([‘message’=> ‘Je bent uitgelogd’], 200); } And added ..

Read more

I want to pass the token to the header to check if the endpoint works and reach null $clientRepository = new ClientRepository(); $client = $clientRepository->createPersonalAccessClient( null, ‘Test Personal Access Client’, ‘http://localhost’ ); DB::table(‘oauth_personal_access_clients’)->insert([ ‘client_id’ => $client->id, ‘created_at’ => new DateTime, ‘updated_at’ => new DateTime, ]); $token = $user->createToken(‘Personal Access Token’)->accessToken; $headers = [‘HTTP_AUTHORIZATION’ => "Bearer ..

Read more

I’m trying to pass the variable cat to search the data related in DB and make a report in excel. Unfortunely i’m getting the following error: Unresolvable dependency resolving [Parameter #1 [ $cat ]] in class movieController Route: Route::get(‘/search/report{cat}’, [movieController::class , ‘export’])->name(‘search-report’); movieCatExport: class movieCatExport implements FromCollection, Responsable, WithHeadings, ShouldAutoSize{ use Exportable; //private $fileName=’usertest.csv’; /** ..

Read more

Hi I’m having some trubles deploying my API on Plesk, I’m adding into a subdomain, the root folder is pointing into public, and when i enter to it appear the laravel framework presentetion, but when I’m trying to use my api this show me a error of not found does somebody knows how can i ..

Read more

I am not very good at php. I have a function to check for an empty field and the correctness of email if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } There is also a code in php.blade in which you need to insert this check @php $split = explode(‘@’, $email); $first ..

Read more

I want to update a TrackResult with a form but i got "false" all time.. Im using id_track with TrackModel and want to update my TrackResult (Trackresult Model). If you need more details from class or other let me know and i’ll update it. My controller : public function updateTrackResult(Request $request, TrackResult $trackResult) { $request->validate([ ..

Read more

I have 5 tables: sales_orders, product_sales_order (pivot table between sales_orders and products), products, shipment, and product_shipment (pivot table between shipment and products). SalesOrder.php class SalesOrder extends Model { public function products() { return $this->belongsToMany(Product::class) ->using(ProductSalesOrder::class) ->withPivot([‘qty’, ‘price’]); } public function shipments() { return $this->hasOne(Shipment::class); } } ProductSalesOrder.php class ProductSalesOrder extends Pivot { public function getSubTotalAttribute() ..

Read more

I’ve tried to use mutator to encrypt a string. It was success to return an encrypted data, but when I try to decrypt this data, it was returning an empty string (""). Is there some mistakes in my code? What is $value actually in this parameter? Thank’s in advance. public function getNationalFamilyCardNumberAttribute() { return Crypt::decryptString($this->attributes[‘national_family_card_number’]); ..

Read more