public static function boot() { parent::boot(); // Delete all links when deleting any LinkableModel. static::deleting(function ($model) { with(App::make('MenuItem'))->where('fmodel', short_name($model))->where('fid', $model->id)->delete(); }); }
public static function boot() { parent::boot(); static::saving(function ($user) { if ($user->skipEvents) { return; } // If we're updating the password, hash it if (Input::exists('password')) { $user->password = Hash::make(Input::get('password')); } }); }
public static function boot() { parent::boot(); static::saving(function ($menuItem) { if ($menuItem->skipEvents) { return; } if (Input::exists('child_menu_id') && !Input::get('child_menu_id')) { $menuItem->child_menu_id = null; } }); static::creating(function ($menuItem) { if ($menuItem->skipEvents) { return; } $menuItem->order = static::where('menu_id', Input::get('menu_id'))->count(); $menuItem->menu_id = Input::get('menu_id'); $menuItem->fmodel = Input::get('fmodel'); $menuItem->fid = Input::get('fid'); }); }