コード例 #1
0
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     AttributeType::deleting(function ($attr) {
         $sub_attrs = Attribute::where('type_id', '=', $attr->id)->get();
         foreach ($sub_attrs as $sa) {
             $sa->delete();
         }
     });
     EntityType::deleting(function ($entity) {
         $entities = $entity->entities;
         foreach ($entities as $e) {
             $e->delete();
         }
     });
     Entity::deleting(function ($entity) {
         $alarms = $entity->alarms;
         foreach ($alarms as $a) {
             $a->delete();
         }
     });
     Alarm::deleting(function ($alarm) {
         $reminders = $alarm->history;
         foreach ($reminders as $r) {
             $r->delete();
         }
     });
 }