mega-commit: migrations, controllers, models, etc.
This commit is contained in:
parent
9732135e90
commit
2c6745e812
70 changed files with 2124 additions and 400 deletions
58
app/Http/Controllers/Managing/CinemaController.php
Normal file
58
app/Http/Controllers/Managing/CinemaController.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Managing;
|
||||
|
||||
class CinemaController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('atleast:employee');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
52
app/Http/Controllers/Managing/GenreController.php
Normal file
52
app/Http/Controllers/Managing/GenreController.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Managing;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GenreController extends Controller
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('atleast:employee');
|
||||
}
|
||||
|
||||
public function showAllGenres() {
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
67
app/Http/Controllers/Managing/MovieController.php
Normal file
67
app/Http/Controllers/Managing/MovieController.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Managing;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MovieController extends Controller
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('atleast:employee');
|
||||
}
|
||||
|
||||
public function showAllMovies() {
|
||||
// has permission READ_MOVIES ?
|
||||
if(!Auth::user()->allowedTo('READ_MOVIES')) {
|
||||
abort(403);
|
||||
}
|
||||
return view('manage.movies.index', ['title' => "Manage Movies", 'movies' => \App\Models\Movie::all()]);
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
$m = \App\Models\Movie::findOrfail($id);
|
||||
return view('manage.movies.movie', ['title' => "Manage Movie", 'movie' => $m, 'showings' => $m->showings]);
|
||||
}
|
||||
|
||||
public function createMovie() {
|
||||
return view('manage.movies.create', ['title' => "Create Movie", 'genres' => \App\Models\Genre::all()]);
|
||||
}
|
||||
|
||||
public function store() {
|
||||
$movie = new \App\Models\Movie();
|
||||
$movie->movie_name = request('movie_name');
|
||||
$movie->movie_description = request('movie_description');
|
||||
$movie->movie_year = request('movie_year');
|
||||
$movie->movie_image = request('movie_image');
|
||||
// $movie->user_id = auth()->user()->user_id;
|
||||
$movie->genre_id = request('genre_id');
|
||||
$movie->save();
|
||||
return redirect()->route('manage.movies');
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
return view('main.movies.movie', ['title' => "Edit Movie", 'movie' => \App\Models\Movie::findOrfail($id)]);
|
||||
}
|
||||
|
||||
public function update($id) {
|
||||
$movie = \App\Models\Movie::findOrfail($id);
|
||||
$movie->movie_name = request('movie_name');
|
||||
$movie->movie_description = request('movie_description');
|
||||
$movie->movie_year = request('movie_year');
|
||||
$movie->movie_image = request('movie_image');
|
||||
// $movie->user_id = auth()->user()->user_id;
|
||||
$movie->genre_id = request('genre_id') !== null ? request('genre_id') : $movie->genre_id;
|
||||
$movie->save();
|
||||
return redirect()->route('manage.movies');
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
$movie = \App\Models\Movie::findOrfail($id);
|
||||
$movie->delete();
|
||||
return redirect()->route('manage.movies');
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,6 @@ class UserDashController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('dash');
|
||||
return view('dash', ['title'=>"Dashboard", 'user'=>auth()->user()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ class Kernel extends HttpKernel
|
|||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'atleast' => \App\Http\Middleware\AtleastRole::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
|
|
18
app/Http/Middleware/AtleastRole.php
Normal file
18
app/Http/Middleware/AtleastRole.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class AtleastRole
|
||||
{
|
||||
|
||||
public function handle($request, Closure $next, $role)
|
||||
{
|
||||
if (!auth()->user()->atleast($role)) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue