forked from aslan/applicant-site
70 lines
2.4 KiB
PHP
70 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\StoreEducationalInstitutionRequest;
|
|
use App\Http\Requests\UpdateEducationalInstitutionRequest;
|
|
use App\Models\EducationalInstitution;
|
|
use Illuminate\Contracts\View\Factory;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Foundation\Application;
|
|
|
|
class EducationalInstitutionController extends Controller
|
|
{
|
|
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
$educationalInstitutions = EducationalInstitution::all();
|
|
return view('catalog.educational-institution.index', compact('educationalInstitutions'));
|
|
}
|
|
|
|
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
return view('catalog.educational-institution.create');
|
|
}
|
|
|
|
public function store(StoreEducationalInstitutionRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
$educationalInstitution = new EducationalInstitution();
|
|
$educationalInstitution->name = $validated['name'];
|
|
$educationalInstitution->description = $validated['description'];
|
|
$educationalInstitution->position = $validated['position'];
|
|
$educationalInstitution->save();
|
|
|
|
return redirect()->route('educational-institutions.index');
|
|
}
|
|
|
|
public function show(EducationalInstitution $educationalInstitution)
|
|
{
|
|
return view('catalog.educational-institution.show', compact('educationalInstitution'));
|
|
}
|
|
|
|
public function edit(EducationalInstitution $educationalInstitution)
|
|
{
|
|
return view('catalog.educational-institution.edit', compact('educationalInstitution'));
|
|
}
|
|
|
|
public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
$educationalInstitution->name = $validated['name'];
|
|
$educationalInstitution->description = $validated['description'];
|
|
$educationalInstitution->position = $validated['position'];
|
|
$educationalInstitution->save();
|
|
|
|
return redirect()->route('educational-institutions.index');
|
|
}
|
|
|
|
public function destroy(EducationalInstitution $educationalInstitution)
|
|
{
|
|
if ($educationalInstitution->faculties()->exists()) {
|
|
return back();
|
|
}
|
|
$educationalInstitution->delete();
|
|
|
|
return redirect()->route('educational-institutions.index');
|
|
}
|
|
}
|