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-02-02 08:17:38 +01:00
|
|
|
$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');
|
2022-12-08 09:30:07 +01:00
|
|
|
}
|
|
|
|
|
2023-02-02 08:17:38 +01:00
|
|
|
public function index()
|
2022-12-08 09:30:07 +01:00
|
|
|
{
|
2023-02-02 08:17:38 +01:00
|
|
|
return view('manage.cinemas.index', ['title' => "Manage Cinemas", 'cinemas' => \App\Models\Cinema::all(), 'users' => \App\Models\User::all()]);
|
2022-12-08 09:30:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|