Created
          December 19, 2017 14:30 
        
      - 
      
- 
        Save AlexMcowkin/d0338b43e31e355a8d3b3134aeba4521 to your computer and use it in GitHub Desktop. 
    Laravel 5.5 boot() in model
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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