middleware('auth'); $this->middleware('atleast:employee'); $this->middleware('permission:READ_CINEMAS')->only('index', 'show'); $this->middleware('permission:CREATE_CINEMAS')->only('create', 'store'); $this->middleware('permission:UPDATE_CINEMAS')->only('edit', 'update'); $this->middleware('permission:DELETE_CINEMAS')->only('destroy'); } public function index() { return view('manage.cinemas.index', ['title' => "Manage Cinemas", 'cinemas' => \App\Models\Cinema::all(), 'users' => \App\Models\User::all()]); } public function edit($id) { $c = \App\Models\Cinema::findOrfail($id); return view('manage.cinemas.cinema', ['title' => "Manage Cinema", 'cinema' => $c, 'rooms' => $c->rooms]); } public function createCinema() { return view('manage.cinemas.create', ['title' => "Create Cinema"]); } public function store() { $cinema = new \App\Models\Cinema(); $cinema->cinema_name = request('cinema_name'); $cinema->address_id = request('address_id'); $cinema->save(); return redirect()->route('manage.cinemas'); } public function show($id) { return view('main.cinemas.cinema', ['title' => "Edit Cinema", 'cinema' => \App\Models\Cinema::findOrfail($id)]); } public function update($id) { $cinema = \App\Models\Cinema::findOrfail($id); $cinema->cinema_name = request('cinema_name'); $cinema->address_id = request('address_id'); $cinema->save(); return redirect()->route('manage.cinemas'); } public function destroy($id) { $cinema = \App\Models\Cinema::findOrfail($id); $cinema->delete(); return redirect()->route('manage.cinemas'); } }