67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Managing;
|
||
|
|
||
|
use App\Http\Controllers\Controller;
|
||
|
|
||
|
class ShowingsController extends Controller
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->middleware('auth');
|
||
|
$this->middleware('atleast:employee');
|
||
|
$this->middleware('permission:READ_SHOWINGS')->only('index', 'show');
|
||
|
$this->middleware('permission:CREATE_SHOWINGS')->only('create', 'store');
|
||
|
$this->middleware('permission:UPDATE_SHOWINGS')->only('edit', 'update');
|
||
|
$this->middleware('permission:DELETE_SHOWINGS')->only('destroy');
|
||
|
}
|
||
|
|
||
|
public function index()
|
||
|
{
|
||
|
return view('manage.showings.index', ['title' => "Manage Showings", 'showings' => \App\Models\Showing::all()]);
|
||
|
}
|
||
|
|
||
|
public function edit($id)
|
||
|
{
|
||
|
$s = \App\Models\Showing::findOrfail($id);
|
||
|
return view('manage.showings.showing', ['title' => "Manage Showing", 'showing' => $s, 'movies' => \App\Models\Movie::all(), 'rooms' => \App\Models\Room::all(), 'cinemas' => \App\Models\Cinema::all()]);
|
||
|
}
|
||
|
|
||
|
public function createShowing()
|
||
|
{
|
||
|
return view('manage.showings.create', ['title' => "Create Showing", 'movies' => \App\Models\Movie::all(), 'rooms' => \App\Models\Room::all()]);
|
||
|
}
|
||
|
|
||
|
public function store()
|
||
|
{
|
||
|
$showing = new \App\Models\Showing();
|
||
|
$showing->movie_id = request('movie_id');
|
||
|
$showing->room_id = request('room_id');
|
||
|
$showing->start_time = request('start_time');
|
||
|
$showing->save();
|
||
|
return redirect()->route('manage.showings');
|
||
|
}
|
||
|
|
||
|
public function show($id)
|
||
|
{
|
||
|
return view('main.showings.showing', ['title' => "Edit Showing", 'showing' => \App\Models\Showing::findOrfail($id)]);
|
||
|
}
|
||
|
|
||
|
public function update($id)
|
||
|
{
|
||
|
$showing = \App\Models\Showing::findOrfail($id);
|
||
|
$showing->movie_id = request('movie_id');
|
||
|
$showing->room_id = request('room_id');
|
||
|
$showing->showing_start = request('showing_start');
|
||
|
$showing->save();
|
||
|
return redirect()->route('manage.showings');
|
||
|
}
|
||
|
|
||
|
public function destroy($id)
|
||
|
{
|
||
|
$showing = \App\Models\Showing::findOrfail($id);
|
||
|
$showing->delete();
|
||
|
return redirect()->route('manage.showings');
|
||
|
}
|
||
|
}
|