2022-12-08 09:30:07 +01:00
|
|
|
<?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');
|
2023-02-02 08:17:38 +01:00
|
|
|
$this->middleware('permission:READ_GENRES')->only('index', 'show');
|
|
|
|
$this->middleware('permission:CREATE_GENRES')->only('create', 'store');
|
|
|
|
$this->middleware('permission:UPDATE_GENRES')->only('edit', 'update');
|
|
|
|
$this->middleware('permission:DELETE_GENRES')->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
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|