CourseWork/app/Http/Controllers/GradeController.php
2024-04-16 13:27:51 +04:00

79 lines
1.6 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Http\Requests\GradePostRequest;
use App\Models\Grade;
use Illuminate\Http\Request;
class GradeController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('grades.index', [
'grades' => Grade::filter()->paginate(10)->withQueryString(),
]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('grades.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(GradePostRequest $request)
{
$grade = Grade::create($request->validated());
return redirect()->route('grades.show', $grade);
}
/**
* Display the specified resource.
*/
public function show(Grade $grade)
{
return view('grades.show', [
'grade' => $grade,
]);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Grade $grade)
{
return view('grades.edit', [
'grade' => $grade,
]);
}
/**
* Update the specified resource in storage.
*/
public function update(GradePostRequest $request, Grade $grade)
{
$grade->update($request->validated());
return redirect()->route('grades.show', $grade);
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Grade $grade)
{
$grade->delete();
return redirect()->route('grades.index');
}
}