use model laravel code example
Example 1: how to create model in laravel
php artisan make:model Flight
Example 2: laravel create model
php artisan make:model Flight
php artisan make:model Flight --migration
php artisan make:model Flight -m
Example 3: laravel create on model
$user = User::create([
'first_name' => 'Taylor',
'last_name' => 'Otwell',
'title' => 'Developer',
]);
$user->title = 'Painter';
$user->isDirty();
$user->isDirty('title');
$user->isDirty('first_name');
$user->isClean();
$user->isClean('title');
$user->isClean('first_name');
$user->save();
$user->isDirty();
$user->isClean();
Example 4: laravel make model
php artisan make:model Flight --factory
php artisan make:model Flight -f
php artisan make:model Flight --seed
php artisan make:model Flight -s
php artisan make:model Flight --controller
php artisan make:model Flight -c
php artisan make:model Flight -mfsc
Example 5: model laravel
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected static function booted()
{
static::addGlobalScope('age', function (Builder $builder) {
$builder->where('age', '>', 200);
});
}
}