/** * * @param string $tag_id ID of tag to delete * @throws KnockCascadeDeleteAttemptException */ public function deleteTag($tag_id) { $tag = Tag::findOrFail($tag_id); if (!$tag == null) { if ($tag->roles->count() == 0) { $tag->delete(); } else { throw new KnockCascadeDeleteAttemptException("Sorry, you cannot delete Tag [" . $tag->name . "] because there are roles and actions associated with it. \n\t\t\t\t\t\tYou must first delete all associated roles and actions before it can be deleted."); } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, $tag_id) { $tag = Tag::findOrFail($tag_id); $action = Knock::createRole($tag->name, Str::slug($request->get('name')), $tag->description, str_replace('"', "'", $request->input('description'))); return redirect('/knock/tags/' . $tag->id)->with('flash_message', 'Role ' . $action->role->name . ' created'); }