/** * @param int $group_id * @param int $affiliation_id * * @return \Illuminate\Http\RedirectResponse */ public function getDeleteAffiliation(int $group_id, int $affiliation_id) { NotificationGroup::findOrFail($group_id)->affiliations()->findOrFail($affiliation_id)->delete(); return redirect()->back()->with('success', 'Affiliation removed!'); }
/** * @return \Illuminate\Support\Collection */ public function getNotificationGroups() : Collection { // Return the groups we already found if we have. if ($this->groups) { return $this->groups; } // Get the groups that are applicable to this // notification type. $this->groups = NotificationGroup::with('alerts')->whereHas('alerts', function ($query) { $query->where('alert', $this->name); })->where('type', $this->type)->get(); return $this->groups; }