Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 /**
  * 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();
     });
 }