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