📜  引导方法 laravel 生命周期 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:54.088000             🧑  作者: Mango

代码示例1
class User extends Model 
{

    public static function boot()
    {
        parent::boot();

        self::creating(function($model){
            // ... code here
        });

        self::created(function($model){
            // ... code here
        });

        self::updating(function($model){
            // ... code here
        });

        self::updated(function($model){
            // ... code here
        });

        self::deleting(function($model){
            // ... code here
        });

        self::deleted(function($model){
            // ... code here
        });
    }

}