model observer laravel
snippet in php

how to create model in laravel

user7293

php artisan make:model Flight

laravel observer

user2349

php artisan make:observer UserObserver --model=User

model observer laravel

user5954

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $table = 'posts';

    protected $fillable = ['title', 'slug', 'content'];

    protected static function boot()
    {
        parent::boot();
        static::saving(function ($model) {
            $model->slug = str_slug($model->title);
        });
    }
}