2022-12-08 09:30:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Managing;
|
|
|
|
|
|
|
|
class CinemaController extends \App\Http\Controllers\Controller
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
$this->middleware('atleast:employee');
|
2023-01-01 20:13:11 +01:00
|
|
|
$this->middleware('permission:manage_cinemas')->only(['create', 'store', 'edit', 'update', 'destroy']);
|
2022-12-08 09:30:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function showAllCinemas()
|
|
|
|
{
|
|
|
|
return view('manage.cinemas.index', ['title' => "Manage Cinemas", 'cinemas' => \App\Models\Cinema::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');
|
|
|
|
}
|
|
|
|
}
|