public static function boot() { parent::boot(); static::saving(function ($model) { if (!isset($model->alias) or empty($model->alias)) { $helper = new Helper(); $model->alias = $helper->aliasify($model->title); } }); }
public static function boot() { parent::boot(); static::saving(function ($model) { if (!isset($model->alias) || empty($model->alias)) { $model->alias = Helper::aliasify($model->title); } }); }
/** * Handle magic method call to allow calling a method to represent * the role to grant and admin with. i.e. * * Auth::authorize($admin)->admin($section); * OR * Auth::authorize($admin)->contentManager($section); * * Then admin and contentManager will become the role granted to that admin * after being aliasified to 'content-manager' * * @param string $method * @param mixed $arguments * @return mixed */ public function __call($method, $arguments) { // Get an alias out of the role (method). $role = Helper::aliasify($method); // Call the grant method with the role alias and the first // element of the arguments. $for_artists = isset($arguments[1]) ? $arguments[1] : null; return $this->grant($role, $arguments[0], $for_artists); }
public function __call($method, $arguments) { $permission = Helper::aliasify($method); array_unshift($arguments, $permission); return call_user_func_array([$this, 'validate'], $arguments); }