cineflex/routes/web.php

127 lines
5.6 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();
return view('main.movies', ['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);
return view('main.movie', ['title' => $movie->movie_name, "movie" => $movie]);
2022-11-23 09:32:34 +01:00
})->name('movie');
Route::get('/cinemas', function () {
return view('main.cinemas', ['title' => "Cinemas", "cinemas" => \App\Models\Cinema::all()]);
})->name('cinemas');
Route::get('/cinema/{id}', function ($id) {
$c = new \App\Models\Cinema();
$cinema = $c->find($id);
return view('main.cinema', ['title' => $cinema->cinema_name, "cinema" => $cinema]);
})->name('cinema');
2022-11-23 09:32:34 +01:00
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
// Employee Home Page
Route::get('/manage', function () {
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(),
]);
})->name('manage');
Route::controller(\App\Http\Controllers\Managing\MovieController::class)->group(function () {
// /manage/movies - CR movies (FB)
Route::get('/manage/movies', [\App\Http\Controllers\Managing\MovieController::class, 'showAllMovies'])->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)
Route::get('/manage/genres', [\App\Http\Controllers\Managing\GenreController::class, 'showAllGenres'])->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)
Route::get('/manage/cinemas', [\App\Http\Controllers\Managing\CinemaController::class, 'showAllCinemas'])->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');
});
// /test/comp/{component}
Route::get('/test/comp/{component}', function ($component) {
switch ($component) {
case 'seat-chooser':
$c = new \App\View\Components\SeatChooser(1);
return $c->render();
default:
return "No component found";
}
})->name('test.comp');