middleware('auth'); $this->middleware('atleast:employee'); $this->middleware('permission:READ_GENRES')->only('index', 'show'); $this->middleware('permission:CREATE_GENRES')->only('create', 'store'); $this->middleware('permission:UPDATE_GENRES')->only('edit', 'update'); $this->middleware('permission:DELETE_GENRES')->only('destroy'); } public function index() { 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'); } }