forked from aslan/applicant-site
refactored Educational Institutions
This commit is contained in:
parent
93592992b7
commit
b11015ae8f
|
@ -14,12 +14,12 @@ class EducationalInstitutionController extends Controller
|
|||
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
$educationalInstitutions = EducationalInstitution::all();
|
||||
return view('educational-institution.index', compact('educationalInstitutions'));
|
||||
return view('catalog.educational-institution.index', compact('educationalInstitutions'));
|
||||
}
|
||||
|
||||
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('educational-institution.create');
|
||||
return view('catalog.educational-institution.create');
|
||||
}
|
||||
|
||||
public function store(StoreEducationalInstitutionRequest $request)
|
||||
|
@ -37,12 +37,12 @@ class EducationalInstitutionController extends Controller
|
|||
|
||||
public function show(EducationalInstitution $educationalInstitution)
|
||||
{
|
||||
return view('educational-institution.show', compact('educationalInstitution'));
|
||||
return view('catalog.educational-institution.show', compact('educationalInstitution'));
|
||||
}
|
||||
|
||||
public function edit(EducationalInstitution $educationalInstitution)
|
||||
{
|
||||
return view('educational-institution.edit', compact('educationalInstitution'));
|
||||
return view('catalog.educational-institution.edit', compact('educationalInstitution'));
|
||||
}
|
||||
|
||||
public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution)
|
||||
|
@ -59,6 +59,9 @@ class EducationalInstitutionController extends Controller
|
|||
|
||||
public function destroy(EducationalInstitution $educationalInstitution)
|
||||
{
|
||||
if ($educationalInstitution->faculties()->exists()) {
|
||||
return back();
|
||||
}
|
||||
$educationalInstitution->delete();
|
||||
|
||||
return redirect()->route('educational-institutions.index');
|
||||
|
|
|
@ -4,8 +4,21 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class EducationalInstitution extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'description',
|
||||
'position',
|
||||
];
|
||||
|
||||
public function faculties(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Faculty', 'educational_institution_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body class="antialiased">
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<header
|
||||
class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom">
|
||||
<ul class="nav col-9 col-md-auto mb-2 justify-content-start mb-md-0">
|
||||
<li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li>
|
||||
<li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
@ -52,10 +53,14 @@
|
|||
<li class="list-group-item"><a href="{{ route('files.index') }}">Файлы</a></li>
|
||||
<li class="list-group-item"><a href="{{ route('admin-reception-screen.index') }}">Экран Приема</a></li>
|
||||
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
|
||||
{{-- <li class="list-group-item"></li>--}}
|
||||
<li class="list-group-item"></li>
|
||||
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
|
||||
<li class="list-group-item"><a href="{{ route('educational-institutions.index') }}">Учебные заведения</a></li>
|
||||
@endif
|
||||
<li class="list-group-item"></li>
|
||||
<li class="list-group-item">Справочники</li>
|
||||
<li class="list-group-item"><a href="{{ route('educational-institutions.index') }}">Учебные
|
||||
заведения</a></li>
|
||||
<li class="list-group-item"><a href="{{ route('faculties.index') }}">Факультеты</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="col-10">@yield('content')</div>
|
||||
|
|
Loading…
Reference in New Issue