Laravel Model

 15 - Oct - 2021

What is a laravel model?

The model is a part of the MVC pattern. which is used to connect with that table. The models allow you to query data in your tables, such as insert new records, update records, and delete records in the table.

Create model in laravel

Now, open the command prompt and go to your project directory using the command prompt. Enter following the below PHP artisan command to create the laravel model. Syntax
php artisan make:model <model-name>
php artisan make:model Product
after running the above command, The Product.php file will be created in the "app/Models" directory. app/Models/Product.php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
    use HasFactory;