app/Observers/CategoryObserver.php
/**
     * Listen to the Entry deleting event.
     *
     * @param Category $category
     * @return void
     */
Listen to the Entry deleting event.
@param Category $category
@return void
Listen to the Entry deleting event . @param Category $category @return void
public function deleting(Category $category)
    {
        Subscription::whereHas('team', function ($q) use ($category) {
            $q->whereHas('category', function ($qq) use ($category) {
                $qq->where('id', $category->id);
            });
        })->delete();
         $category->teams()->delete();
         $category->allUsers()->delete();
         $category->activities()->delete();
         $category->events()->delete();
         $category->heroes()->delete();
         $category->champions()->delete();
         $category->coaches()->delete();
    }
public function deleting ( Category $ category ) { Subscription :: whereHas ( 'team' , function ( $ q ) use ( $ category ) { $ q -> whereHas ( 'category' , function ( $ qq ) use ( $ category ) { $ qq -> where ( 'id' , $ category -> id ) ; } ) ; } ) -> delete ( ) ; $ category -> teams ( ) -> delete ( ) ; $ category -> allUsers ( ) -> delete ( ) ; $ category -> activities ( ) -> delete ( ) ; $ category -> events ( ) -> delete ( ) ; $ category -> heroes ( ) -> delete ( ) ; $ category -> champions ( ) -> delete ( ) ; $ category -> coaches ( ) -> delete ( ) ; }
Listen to the Entry deleting event.
Listen to the Entry deleting event .