middleware('auth'); $this->middleware('atleast:employee'); $this->middleware('permission:manage_genres')->only(['create', 'store', 'edit', 'update', 'destroy']); } public function showAllGenres() { return view('manage.genres.index', ['title' => "Manage Genres", 'genres' => \App\Models\Genre::all()]); } public function edit($id) { $g = \App\Models\Genre::findOrfail($id); return view('manage.genres.genre', ['title' => "Manage Genre", 'genre' => $g, 'movies' => $g->movies]); } public function createGenre() { return view('manage.genres.create', ['title' => "Create Genre"]); } public function store() { $genre = new \App\Models\Genre(); $genre->genre_name = request('genre_name'); $genre->save(); return redirect()->route('manage.genres'); } public function show($id) { return view('main.genres.genre', ['title' => "Edit Genre", 'genre' => \App\Models\Genre::findOrfail($id)]); } public function update($id) { $genre = \App\Models\Genre::findOrfail($id); $genre->genre_name = request('genre_name'); $genre->save(); return redirect()->route('manage.genres'); } public function destroy($id) { $genre = \App\Models\Genre::findOrfail($id); $genre->delete(); return redirect()->route('manage.genres'); } }