forked from aslan/applicant-site
refactor educationalInstitution
This commit is contained in:
parent
ebade01982
commit
941da60c6f
|
@ -39,13 +39,13 @@ class FacultyController extends Controller
|
||||||
return redirect()->route('faculties.index');
|
return redirect()->route('faculties.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Faculty $faculty)
|
public function edit(Faculty $faculty): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
|
||||||
{
|
{
|
||||||
$educationalInstitutions = EducationalInstitution::pluck('name', 'id');
|
$educationalInstitutions = EducationalInstitution::pluck('name', 'id');
|
||||||
return view('catalog.faculty.edit', compact('faculty', 'educationalInstitutions'));
|
return view('catalog.faculty.edit', compact('faculty', 'educationalInstitutions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(UpdateFacultyRequest $request, Faculty $faculty)
|
public function update(UpdateFacultyRequest $request, Faculty $faculty): RedirectResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class FacultyController extends Controller
|
||||||
return redirect()->route('faculties.index');
|
return redirect()->route('faculties.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Faculty $faculty)
|
public function destroy(Faculty $faculty): RedirectResponse
|
||||||
{
|
{
|
||||||
$faculty->delete();
|
$faculty->delete();
|
||||||
return redirect()->route('faculties.index');
|
return redirect()->route('faculties.index');
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class UpdateEducationalInstitutionRequest extends FormRequest
|
class UpdateEducationalInstitutionRequest extends FormRequest
|
||||||
{
|
{
|
||||||
|
@ -17,14 +19,19 @@ class UpdateEducationalInstitutionRequest extends FormRequest
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
* @return array<string, ValidationRule|array|string>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'position' => 'int|max:255',
|
'position' => 'int|max:255',
|
||||||
'name' => 'required|string|max:255|unique:educational_institutions,name',
|
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
"unique:educational_institutions,name,{$this->educational_institution->id}",
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1 class="">Изменить учебное заведение</h1>
|
<h1 class="">Изменить учебное заведение</h1>
|
||||||
{{ Form::open(['url' => route('educational-institutions.update', $educationalInstitution), 'method' => 'PATCH', 'class' => '']) }}
|
{{ Form::model($educationalInstitution, ['route' => ['educational-institutions.update', $educationalInstitution], 'method' => 'PATCH', 'class' => '']) }}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div>
|
<div>
|
||||||
{{ Form::label('position', 'Позиция') }}
|
{{ Form::label('position', 'Позиция') }}
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
@foreach($educationalInstitutions as $educationalInstitution)
|
@foreach($educationalInstitutions as $educationalInstitution)
|
||||||
<tr class="">
|
<tr class="">
|
||||||
<th scope="row">{{ $educationalInstitution->position }}</th>
|
<th scope="row">{{ $educationalInstitution->position }}</th>
|
||||||
<td>{{ $educationalInstitution->name }}</td>
|
<td><a href="{{ route('educational-institutions.show', $educationalInstitution) }}">{{ $educationalInstitution->name }}</a></td>
|
||||||
<td>{{ $educationalInstitution->description }}</td>
|
<td>{{ Str::words($educationalInstitution->description, 10, '...') }}</td>
|
||||||
<td><a href="{{ route("educational-institutions.edit", $educationalInstitution) }}"
|
<td class="col-3"><a href="{{ route("educational-institutions.edit", $educationalInstitution) }}"
|
||||||
class="btn btn-secondary">редактировать</a>
|
class="btn btn-secondary">редактировать</a>
|
||||||
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
|
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
|
||||||
href="{{ route('educational-institutions.destroy', $educationalInstitution) }}"
|
href="{{ route('educational-institutions.destroy', $educationalInstitution) }}"
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
@extends('layouts.admin-layout')
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@auth()
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h2>Название</h2>
|
||||||
|
<p>{{ $educationalInstitution->name }}</p>
|
||||||
|
<h2>Описание</h2>
|
||||||
|
<p>{{ $educationalInstitution->description }}</p>
|
||||||
|
<h2>Позиция</h2>
|
||||||
|
<p>{{ $educationalInstitution->position }}</p>
|
||||||
|
<h2>Факультеты</h2>
|
||||||
|
@foreach($educationalInstitution->faculties as $faculty)
|
||||||
|
<p><a href="{{ route('faculties.show', $faculty) }}">{{ $faculty->name }}</a></p>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endauth
|
||||||
|
@endsection
|
Loading…
Reference in New Issue