public function __call($method, $parameters) { $taggableModel = Config::get('module.tag.taggableModel'); if (array_key_exists($method, $taggableModel)) { return $this->morphedByMany($taggableModel[$method], 'taggable'); } return parent::__call($method, $parameters); }
/** * Model event. * * @return void */ public static function boot() { parent::boot(); // Delete hierarchies first. static::deleting(function ($model) { $model->eventProcess('deleting', $model); // if delete the parent also delete the children $model->children()->delete(); // use soft delete so do not want to detach // $model->children()->detach(); // $model->parents()->detach(); }); static::restoring(function ($model) { $model->eventProcess('restoring', $model); // if restore the parent also restore all of the children // $model->children()->restore(); }); }