Skip to main content
Best practices
0 votes
1 replies
33 views

I have two models with global scopes. #[ScopedBy(UserScope::class)] class User {} #[ScopedBy(ViewerScope::class)] class Viewer extends User {} The scope just checks if class instance has is_viewer ==...
Denys Siebov's user avatar
2 votes
2 answers
177 views

I want to run an action after any model got deleted, but currently it seems like I do something wrong.. I already get the Model before I delete it, so the event should get fired. As I do already some ...
MaxWeb's user avatar
  • 169
0 votes
1 answer
61 views

I would like to get back within a with() the last entry of a modal which is not null on a certain column. I know that it is possible to simply get the last entry with the following function in the ...
Matthias's user avatar
2 votes
1 answer
1k views

I'm working on a Laravel project and I'm trying to set up a one-to-many relationship between two models How can I create a new user and associate multiple posts with that user using Eloquent? How do ...
Harshad Kanani's user avatar
0 votes
1 answer
82 views

So basicly i have started working with laravel. And to this moment i have been writing migrations and defining the fields there. And after that i should create a model related to it and define the ...
p1rate_k1ng's user avatar
0 votes
0 answers
44 views

I have a complex query such as $drivers = Drivers::where('somecondition', $request->condition) ->with([ 'license' => function($query) { $query->where('is_active', 1)...
Yeak's user avatar
  • 2,530
-2 votes
1 answer
103 views

I have many routes, and for a single page (my homepage) I need to sample almost all of my models. I do it like that: use App\Models\Aa; use App\Models\Bb; use App\Models\Cc; // and so on ... Route::...
yossi's user avatar
  • 3,174
-1 votes
1 answer
347 views

I have a Laravel app and a model Category. It has a relation to itself called parent Category.php public function parent(): BelongsTo { return $this->belongsTo(self::class, 'parent_uuid', 'uuid'...
Nelu Moraru's user avatar

15 30 50 per page
1
2 3 4 5
7