Laravel Eloquent ist an object-relational-mapper, an ORM, that makes working with databases a joy. While you still need a basic understanding about your database and how writing queries works, Laravel Eloquent provides convenient methos to insert, update and query this data. Eloquent uses the active record pattern where every column in the database table is accessible via a magic method of the related Eloquent Model.
The Eloquent relationships on the User model for this setup looks as simple as that: public function posts(): HasMany { return $this->hasMany(Post::class); } public function comments(): HasMany { return $this->hasMany(Comment::class); }
When you query your database with Laravel Eloquent, you can add as many where conditions to the query as you want.