コード例 #1
0
ファイル: Topic.php プロジェクト: christiancable/nexus5ive
 public static function boot()
 {
     parent::boot();
     // Attach event handler for deleting a topic
     Topic::deleting(function ($topic) {
         /*
                     to keep a cascading delete when using softDeletes we must remove the related models here
         */
         $children = ['posts', 'views'];
         Log::info("Deleting Topic {$topic->title} - {$topic->id}");
         foreach ($children as $child) {
             if ($topic->{$child}()) {
                 Log::info(" - removing topic->{$child}");
                 $topic->{$child}()->delete();
             }
         }
     });
 }