+1 vote
in Laravel by
What are Models?

1 Answer

0 votes
by

With Laravel, each database table can have a model representation using a model file which can be used to interact with that table using Laravel Eloquent ORM.

We can create a model using this artisan command:

php artisan make:model Post

This will create a file in the models’ directory and will look like below:

class Post extends Model

{

    /**

     * The attributes that are mass assignable.

     *

     * @var array

     */

    protected $fillable = [];

    /**

     * The attributes that should be hidden for arrays.

     *

     * @var array

     */

    protected $hidden = [];

}

A Model can have properties like table, fillable, hidden, etc which defines properties of the table and model.

Related questions

0 votes
asked Oct 14, 2023 in Generative AI by rajeshsharma
0 votes
asked Jul 21, 2023 in Deep Learning by rahuljain1
...