Model in Laravel

The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.


N.B, If table’s name is Articles (plural) then we should create a model named Article (singular) then the model will communicate automatically if other then we have to inform the name of the table to the model. It will also help in model relationship.


Model তৈরির জন্য:

php artisan make:model Article -m

Then table migration will be Articles and model name will be Article


N.B, Mass Assignment is for getting data to model from controller for storing to database.


Model Class এ নিচের Code লিখতে হবে:

protected $table = '$users';

protected $primaryKey='$user_id';

protected $fillable = ['id', 'password'];


  • 249
  • 308
  • By Bablu Ahmed
  • Posted 1 year ago