public function showSection($nameHead, $nameSection) { $headForum = forumHead::where('link_route', $nameHead)->firstOrFail(); $sectionForum = forumSection::where('link_section_route', $nameSection)->firstOrFail(); $topics = Topic::where('important', 0)->latest('updated_at')->paginate(20); if (!\Auth::guest() && \Auth::user()->isAdmin() || !\Auth::guest() && \Auth::user()->isMod()) { return view('forum.showSection', compact('sectionForum', 'topics')); } else { if ($sectionForum->forumHead['forOrg'] == 0 && $sectionForum->forumHead['forBiz'] == 0) { return view('forum.showSection', compact('sectionForum', 'topics')); } else { if (!\Auth::guest() && $sectionForum->forumHead['forOrg'] == \Auth::user()->queryLeaderHeads()) { return view('forum.showSection', compact('sectionForum', 'topics')); } elseif (!\Auth::guest() && $sectionForum->forumHead['forOrg'] == \Auth::user()->queryMemberHeads()) { return view('forum.showSection', compact('sectionForum', 'topics')); } elseif (!\Auth::guest() && $sectionForum->forumHead['forBiz'] == \Auth::user()->queryBmemberHeads()) { return view('forum.showSection', compact('sectionForum', 'topics')); } elseif (!\Auth::guest() && $sectionForum->forumHead['forBiz'] == \Auth::user()->queryBleaderHeads()) { return view('forum.showSection', compact('sectionForum', 'topics')); } else { flash()->error('Nie masz dostępu do tego działu!'); return redirect('/forum'); } } } }
public function storeForumHead(CreateForumHead $request) { forumHead::create(['name' => $request->input('head_name'), 'link_route' => str_replace(" ", "-", str_replace(array("ą", "Ą", "ę", "Ę", "ó", "Ó", "ś", "Ś", "ł", "Ł", "ż", "Ż", "ź", "Ź", "ć", "Ć", "ń", "Ń"), array("a", "A", "e", "E", "o", "O", "s", "S", "l", "L", "z", "Z", "z", "Z", "c", "C", "n", "N"), strtolower($request->input('head_name')))), 'forOrg' => $request->input('forOrg'), 'forBiz' => $request->input('forBiz'), 'info' => $request->input('head_info')]); flash()->success('Udało Ci się utworzyć dział o nazwie <b>' . $request->input('name') . '</b>!'); return redirect('/admin'); }