70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\admin\Catalog;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\admin\Catalog\StoreEducationFormRequest;
|
|
use App\Http\Requests\admin\Catalog\UpdateEducationFormRequest;
|
|
use App\Models\EducationForm;
|
|
use Illuminate\Contracts\View\Factory;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Foundation\Application;
|
|
|
|
class EducationFormController extends Controller
|
|
{
|
|
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
$forms = EducationForm::all();
|
|
return view('admin.catalog.education_form.index', compact('forms'));
|
|
}
|
|
|
|
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
return view('admin.catalog.education_form.create');
|
|
}
|
|
|
|
public function store(StoreEducationFormRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
$form = new EducationForm();
|
|
$form->name = $validated['name'];
|
|
$form->description = $validated['description'];
|
|
$form->slug = $validated['slug'];
|
|
$form->save();
|
|
|
|
return redirect()->route('education_forms.index');
|
|
}
|
|
|
|
public function show(EducationForm $educationForm): View|Factory|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
$directions = $educationForm->directions;
|
|
return view('admin.catalog.education_form.show', compact('educationForm', 'directions'));
|
|
}
|
|
|
|
public function edit(EducationForm $educationForm)
|
|
{
|
|
return view('admin.catalog.education_form.edit', compact('educationForm'));
|
|
}
|
|
|
|
public function update(UpdateEducationFormRequest $request, EducationForm $educationForm)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
$educationForm->name = $validated['name'];
|
|
$educationForm->description = $validated['description'];
|
|
$educationForm->slug = $validated['slug'];
|
|
$educationForm->save();
|
|
|
|
return redirect()->route('education_forms.index');
|
|
}
|
|
|
|
public function destroy(EducationForm $educationForm)
|
|
{
|
|
if ($educationForm->directions()->exists()) {
|
|
return back();
|
|
}
|
|
$educationForm->delete();
|
|
return redirect()->route('education_forms.index');
|
|
}
|
|
}
|