cineflex/routes/web.php

150 lines
8 KiB
PHP
Raw Normal View History

2022-11-23 09:32:34 +01:00
<?php
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
$s = new \App\Models\Showing();
return view('main.home', ['title' => "Home", "showings" => $s->nowPlaying()->unique('movie_id'), "cinemas" => \App\Models\Cinema::all()]);
2022-11-23 09:32:34 +01:00
})->name('home');
Route::get('/movies', function () {
$s = new \App\Models\Showing();
2023-01-01 20:13:11 +01:00
return view('main.movies.index', ['title' => "Movies", "showings" => $s->nowPlaying()->unique('movie_id')]);
2022-11-23 09:32:34 +01:00
})->name('movies');
Route::get('/movie/{id}', function ($id) {
$m = new \App\Models\Movie();
$movie = $m->find($id);
2023-01-01 20:13:11 +01:00
return view('main.movies.movie', ['title' => $movie->movie_name, "movie" => $movie]);
2022-11-23 09:32:34 +01:00
})->name('movie');
Auth::routes();
// account
Route::get('/logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name('logout');
2022-11-23 09:32:34 +01:00
Route::get('/dash', [App\Http\Controllers\UserDashController::class, 'index'])->name('dash');
// FORMAT: {ROUTE} - {C &| R &| U &| D} {what} {F || B}
// CRUD - Create Read Update Delete
// FB - Frontend Backend
2023-01-01 20:13:11 +01:00
// main
Route::get('/cinemas', [App\Http\Controllers\Main\CinemaController::class, 'showAllCinemas'])->name('cinemas');
Route::get('/cinema/{id}', [App\Http\Controllers\Main\CinemaController::class, 'show'])->name('cinema');
Route::get('/showings', [App\Http\Controllers\Main\ShowingController::class, 'showAllShowings'])->name('showings');
Route::get('/showing/{id}', [App\Http\Controllers\Main\ShowingController::class, 'show'])->name('showing');
2023-02-02 08:17:38 +01:00
Route::get('/showing/{id}/order', [App\Http\Controllers\Main\ShowingController::class, 'order'])->name('showing.order');
2023-01-01 20:13:11 +01:00
2023-02-02 08:17:38 +01:00
Route::get('/movies', [App\Http\Controllers\Main\MovieController::class, 'moviesNowShowing'])->name('movies');
2023-01-01 20:13:11 +01:00
Route::get('/movie/{id}', [App\Http\Controllers\Main\MovieController::class, 'show'])->name('movie');
Route::get('/genres', [App\Http\Controllers\Main\GenreController::class, 'showAllGenres'])->name('genres');
Route::get('/genre/{id}', [App\Http\Controllers\Main\GenreController::class, 'show'])->name('genre');
// Employee Home Page
Route::get('/manage', function () {
2023-02-02 08:17:38 +01:00
if (!auth()->user()->atleast('employee')) {
return redirect()->route('home');
}
return view('manage.index', [
'title' => "Manage",
'user' => auth()->user(),
'users' => \App\Models\User::all(),
'showings' => \App\Models\Showing::all(),
'movies' => \App\Models\Movie::all(),
'genres' => \App\Models\Genre::all(),
2023-02-02 08:17:38 +01:00
]);
})->name('manage');
Route::controller(\App\Http\Controllers\Managing\MovieController::class)->group(function () {
// /manage/movies - CR movies (FB)
2023-02-02 08:17:38 +01:00
Route::get('/manage/movies', [\App\Http\Controllers\Managing\MovieController::class, 'index'])->name('manage.movies');
Route::post('/manage/movies', [\App\Http\Controllers\Managing\MovieController::class, 'store'])->name('manage.movies');
// /manage/movies/create - C movie (F)
Route::get('/manage/movies/create', [\App\Http\Controllers\Managing\MovieController::class, 'createMovie'])->name('manage.movies.create');
// no post, handled by POST /movies
// /manage/movies/{id} - RUD movie (FB)
Route::get('/manage/movie/{id}', [\App\Http\Controllers\Managing\MovieController::class, 'edit'])->name('manage.movie');
Route::put('/manage/movie/{id}', [\App\Http\Controllers\Managing\MovieController::class, 'update'])->name('manage.movie');
Route::delete('/manage/movie/{id}', [\App\Http\Controllers\Managing\MovieController::class, 'destroy'])->name('manage.movie');
});
Route::controller(\App\Http\Controllers\Managing\GenreController::class)->group(function () {
// /manage/genres - CR genres (FB)
2023-02-02 08:17:38 +01:00
Route::get('/manage/genres', [\App\Http\Controllers\Managing\GenreController::class, 'index'])->name('manage.genres');
Route::post('/manage/genres', [\App\Http\Controllers\Managing\GenreController::class, 'store'])->name('manage.genres');
// /manage/genres/create - C genre (F)
Route::get('/manage/genres/create', [\App\Http\Controllers\Managing\GenreController::class, 'createGenre'])->name('manage.genres.create');
// no post, handled by POST /genres
// /manage/genres/{id} - RUD genre (FB)
Route::get('/manage/genre/{id}', [\App\Http\Controllers\Managing\GenreController::class, 'edit'])->name('manage.genre');
Route::put('/manage/genre/{id}', [\App\Http\Controllers\Managing\GenreController::class, 'update'])->name('manage.genre');
Route::delete('/manage/genre/{id}', [\App\Http\Controllers\Managing\GenreController::class, 'destroy'])->name('manage.genre');
});
Route::controller(\App\Http\Controllers\Managing\CinemaController::class)->group(function () {
// /manage/cinemas - CR cinemas (FB)
2023-02-02 08:17:38 +01:00
Route::get('/manage/cinemas', [\App\Http\Controllers\Managing\CinemaController::class, 'index'])->name('manage.cinemas');
Route::post('/manage/cinemas', [\App\Http\Controllers\Managing\CinemaController::class, 'store'])->name('manage.cinemas');
// /manage/cinemas/create - C cinema (F)
Route::get('/manage/cinemas/create', [\App\Http\Controllers\Managing\CinemaController::class, 'createCinema'])->name('manage.cinemas.create');
// no post, handled by POST /cinemas
// /manage/cinemas/{id} - RUD cinema (FB)
Route::get('/manage/cinema/{id}', [\App\Http\Controllers\Managing\CinemaController::class, 'edit'])->name('manage.cinema');
Route::put('/manage/cinema/{id}', [\App\Http\Controllers\Managing\CinemaController::class, 'update'])->name('manage.cinema');
Route::delete('/manage/cinema/{id}', [\App\Http\Controllers\Managing\CinemaController::class, 'destroy'])->name('manage.cinema');
});
2023-01-01 20:13:11 +01:00
Route::controller(\App\Http\Controllers\Managing\ShowingsController::class)->group(function () {
// /manage/showings - CR showings (FB)
2023-02-02 08:17:38 +01:00
Route::get('/manage/showings', [\App\Http\Controllers\Managing\ShowingsController::class, 'index'])->name('manage.showings');
2023-01-01 20:13:11 +01:00
Route::post('/manage/showings', [\App\Http\Controllers\Managing\ShowingsController::class, 'store'])->name('manage.showings');
// /manage/showings/create - C showing (F)
Route::get('/manage/showings/create', [\App\Http\Controllers\Managing\ShowingsController::class, 'createShowing'])->name('manage.showings.create');
// no post, handled by POST /showings
// /manage/showings/{id} - RUD showing (FB)
Route::get('/manage/showing/{id}', [\App\Http\Controllers\Managing\ShowingsController::class, 'edit'])->name('manage.showing');
Route::put('/manage/showing/{id}', [\App\Http\Controllers\Managing\ShowingsController::class, 'update'])->name('manage.showing');
Route::delete('/manage/showing/{id}', [\App\Http\Controllers\Managing\ShowingsController::class, 'destroy'])->name('manage.showing');
});
2023-02-02 08:17:38 +01:00
Route::controller(\App\Http\Controllers\Managing\UsersController::class)->group(function () {
// /manage/users - CR users (FB)
Route::get('/manage/users', [\App\Http\Controllers\Managing\UsersController::class, 'index'])->name('manage.users');
Route::post('/manage/users', [\App\Http\Controllers\Managing\UsersController::class, 'store'])->name('manage.users');
// /manage/users/create - C user (F)
Route::get('/manage/users/create', [\App\Http\Controllers\Managing\UsersController::class, 'createUser'])->name('manage.users.create');
// no post, handled by POST /users
// /manage/users/{id} - RUD user (FB)
Route::get('/manage/user/{id}', [\App\Http\Controllers\Managing\UsersController::class, 'show'])->name('manage.user');
Route::put('/manage/user/{id}', [\App\Http\Controllers\Managing\UsersController::class, 'update'])->name('manage.user');
Route::delete('/manage/user/{id}', [\App\Http\Controllers\Managing\UsersController::class, 'destroy'])->name('manage.user');
});