Skip to content

Model Usage

In a Laravel project, models represent the connection between your database tables and your application logic. They rely on Eloquent ORM, Laravel’s built-in object-relational mapper.

Each model typically corresponds to a single database table

Database TableLaravel Model
usersApp\Models\User
postsApp\Models\Post
ordersApp\Models\Order

Eloquent allows you to interact with your data as PHP objects while providing powerful features such as:

  • Relationships (hasOne, hasMany, belongsTo, etc.)
  • Dynamic queries (User::where(‘active’, true)->get())
  • Simplified create/update operations ($user->save())
  • Attribute protection through $fillable or $guarded