cineflex/app/Http/Controllers/Managing/GenreController.php

57 lines
1.9 KiB
PHP
Raw Normal View History

<?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');
}
2023-02-02 08:17:38 +01:00
public function index() {
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');
}
}