Compare commits

..

No commits in common. "f3c98e1548bdf3579917a9327fa1ab50367c348d" and "4cb1422b09bce35e73ceb4296533c2518dbdf771" have entirely different histories.

5 changed files with 24 additions and 108 deletions

View File

@ -9,8 +9,6 @@ use App\Models\EducationalInstitution;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class EducationalInstitutionController extends Controller class EducationalInstitutionController extends Controller
{ {
@ -36,16 +34,6 @@ class EducationalInstitutionController extends Controller
$educationalInstitution->position = $validated['position']; $educationalInstitution->position = $validated['position'];
$educationalInstitution->save(); $educationalInstitution->save();
Log::channel('app')
->info(
'CREATE учеб. заведение {educationalInstitution} - user {user}',
[
'user' => Auth::user()->name,
'educationalInstitution' => $educationalInstitution->name,
'data' => $validated
]
);
return redirect()->route('educational_institutions.index'); return redirect()->route('educational_institutions.index');
} }
@ -62,24 +50,11 @@ class EducationalInstitutionController extends Controller
public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution) public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution)
{ {
$validated = $request->validated(); $validated = $request->validated();
$oldData = $educationalInstitution->toArray();
$educationalInstitution->name = $validated['name']; $educationalInstitution->name = $validated['name'];
$educationalInstitution->description = $validated['description']; $educationalInstitution->description = $validated['description'];
$educationalInstitution->position = $validated['position']; $educationalInstitution->position = $validated['position'];
$educationalInstitution->slug = $validated['slug']; $educationalInstitution->slug = $validated['slug'];
Log::channel('app')
->warning(
'UPDATE учеб. заведение {educationalInstitution} - user {user}',
[
'user' => Auth::user()->name,
'faculty' => $educationalInstitution->name,
'oldData' => $oldData,
'newData' => $validated
]
);
$educationalInstitution->save(); $educationalInstitution->save();
return redirect()->route('educational_institutions.index'); return redirect()->route('educational_institutions.index');
@ -88,26 +63,8 @@ class EducationalInstitutionController extends Controller
public function destroy(EducationalInstitution $educationalInstitution) public function destroy(EducationalInstitution $educationalInstitution)
{ {
if ($educationalInstitution->faculties()->exists()) { if ($educationalInstitution->faculties()->exists()) {
Log::channel('app')
->error(
'NOT DELETE учеб. заведение {educationalInstitution} - user {user}',
[
'user' => Auth::user()->name,
'educationalInstitution' => $educationalInstitution->name,
'data' => $educationalInstitution->toArray(),
]
);
return back(); return back();
} }
Log::channel('app')
->critical(
'DELETE учеб. заведение {educationalInstitution} - user {user}',
[
'user' => Auth::user()->name,
'educationalInstitution' => $educationalInstitution->name,
'data' => $educationalInstitution->toArray(),
]
);
$educationalInstitution->delete(); $educationalInstitution->delete();
return redirect()->route('educational_institutions.index'); return redirect()->route('educational_institutions.index');

View File

@ -16,24 +16,8 @@ class StoreEducationalInstitutionRequest extends FormRequest
return [ return [
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:educational_institutions,name', 'name' => 'required|string|max:255|unique:educational_institutions,name',
'description' => 'nullable|string', 'description' => 'string',
'slug' => 'nullable|string|max:255|unique:educational_institutions,slug', 'slug' => 'required|string|max:255|unique:educational_institutions,slug',
];
}
public function messages(): array
{
return [
'position.required' => 'Поле позиция обязательно.',
'position.int' => 'Позиция должно быть целым числом.',
'position.numeric' => 'Позиция должно быть числом.',
'position.max' => 'Позиция не должен быть больше :max',
'name.required' => 'Поле название обязательно.',
'name.string' => 'Поле название должен быть строкой.',
'name.max' => 'Поле название не должен превышать :max символов.',
'name.unique' => 'Название уже занят.',
'description.string' => 'Поле описание должен быть строкой.',
'slug.string' => 'Поле URL должен быть строкой.',
'slug.max' => 'Поле URL не должен превышать :max символов.',
]; ];
} }
} }

View File

@ -16,7 +16,7 @@ class UpdateEducationalInstitutionRequest extends FormRequest
{ {
return [ return [
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'nullable|string', 'description' => 'string',
'slug' => [ 'slug' => [
'required', 'required',
'string', 'string',
@ -31,21 +31,4 @@ class UpdateEducationalInstitutionRequest extends FormRequest
], ],
]; ];
} }
public function messages(): array
{
return [
'position.required' => 'Поле позиция обязательно.',
'position.int' => 'Позиция должно быть целым числом.',
'position.numeric' => 'Позиция должно быть числом.',
'position.max' => 'Позиция не должен быть больше :max',
'name.required' => 'Поле название обязательно.',
'name.string' => 'Поле название должен быть строкой.',
'name.max' => 'Поле название не должен превышать :max символов.',
'name.unique' => 'Название уже занят.',
'description.string' => 'Поле описание должен быть строкой.',
'slug.string' => 'Поле URL должен быть строкой.',
'slug.max' => 'Поле URL не должен превышать :max символов.',
];
}
} }

View File

@ -28,7 +28,7 @@
<span class="text-danger">*</span> <span class="text-danger">*</span>
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ Form::number('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name'), 'required']) }} {{ Form::text('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name'), 'required']) }}
<div class="invalid-feedback"> <div class="invalid-feedback">
Поле "Название" обязательно! Поле "Название" обязательно!
</div> </div>

View File

@ -4,58 +4,50 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1 class="">Изменить учебное заведение</h1> <h1 class="">Изменить учебное заведение</h1>
{{ Form::model($educationalInstitution, ['route' => ['educational_institutions.update', $educationalInstitution], 'method' => 'PATCH', 'class' => 'needs-validation', 'novalidate']) }} {{ Form::model($educationalInstitution, ['route' => ['educational_institutions.update', $educationalInstitution], 'method' => 'PATCH', 'class' => '']) }}
<div class="col"> <div class="col">
<div>
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2"> <div class="mt-2">
{{ Form::label('position', 'Позиция', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.position')]) }} {{ Form::text('position', $educationalInstitution->position, ['class' => 'form-control']) }}
<span class="text-danger">*</span>
</div> </div>
<div class="mt-1"> <div>
{{ Form::number('position', $educationalInstitution->position, ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.position'), 'required']) }}
<div class="invalid-feedback">
Поле "Позиция" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('position') }} {{ $errors->first('position') }}
@endif @endif
</div> </div>
<div>
{{ Form::label('name', 'Название') }}
</div>
<div class="mt-2"> <div class="mt-2">
{{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name')]) }} {{ Form::text('name', $educationalInstitution->name, ['class' => 'form-control']) }}
<span class="text-danger">*</span>
</div> </div>
<div class="mt-1"> <div>
{{ Form::text('name', $educationalInstitution->name, ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name'), 'required']) }}
<div class="invalid-feedback">
Поле "Название" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('name') }} {{ $errors->first('name') }}
@endif @endif
</div> </div>
<div>
{{ Form::label('description', 'Описание') }}
</div>
<div class="mt-2"> <div class="mt-2">
{{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }} {{ Form::text('description', $educationalInstitution->description, ['class' => 'form-control']) }}
</div> </div>
<div class="mt-1"> <div>
{{ Form::text('description', $educationalInstitution->description, ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }}
</div>
<div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('description') }} {{ $errors->first('description') }}
@endif @endif
</div> </div>
<div class="mt-2"> <div class="mt-3">
{{ Form::label('slug', 'URL', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.slug')]) }} {{ Form::label('slug', 'URL') }}
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::text('slug', $educationalInstitution->slug, ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.slug')]) }} {{ Form::text('slug', $educationalInstitution->slug, ['class' => 'form-control']) }}
</div> </div>
<div class="text-danger"> <div>
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('slug') }} {{ $errors->first('slug') }}
@endif @endif