Skip to content

Instantly share code, notes, and snippets.

@AlexMcowkin
Created December 19, 2017 14:30
Show Gist options
  • Save AlexMcowkin/d0338b43e31e355a8d3b3134aeba4521 to your computer and use it in GitHub Desktop.
Save AlexMcowkin/d0338b43e31e355a8d3b3134aeba4521 to your computer and use it in GitHub Desktop.
Laravel 5.5 boot() in model
public static function boot()
{
parent::boot();
self::deleting(function($model) {
if($model->default == 1)
return false;
});
self::updated(function($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
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment