diff --git a/app/Helpers/PositionHelper.php b/app/Helpers/PositionHelper.php index 906f875..a0654c9 100644 --- a/app/Helpers/PositionHelper.php +++ b/app/Helpers/PositionHelper.php @@ -4,6 +4,7 @@ namespace App\Helpers; use App\Models\Direction; use App\Models\DirectionProfile; +use App\Models\EntranceExamination; use App\Models\ExaminationType; use App\Models\Faculty; use App\Models\EducationalInstitution; @@ -53,4 +54,10 @@ class PositionHelper $maxPosition = ExaminationType::max('position'); return $maxPosition >= 254 ? 255 : $maxPosition + 1; } + + public static function entranceExamination() + { + $maxPosition = EntranceExamination::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } } diff --git a/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php index 2cc0e29..d68c127 100644 --- a/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php +++ b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php @@ -12,6 +12,8 @@ use App\Models\Subject; use App\Models\SubjectType; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; class EntranceExaminationController extends Controller { @@ -51,6 +53,12 @@ class EntranceExaminationController extends Controller $entranceExamination->subject_type_id = $validated['subject_type_id']; $entranceExamination->save(); + Log::channel('app') + ->info( + 'CREATE вступ. испытания {entranceExamination} - user {user}', + ['user' => Auth::user()->name, 'entranceExamination' => $entranceExamination->name, 'data' => $validated] + ); + return redirect()->route('entrance_examinations.index'); } @@ -85,6 +93,7 @@ class EntranceExaminationController extends Controller EntranceExamination $entranceExamination ): RedirectResponse { $validated = $request->validated(); + $oldData = $entranceExamination->toArray(); $entranceExamination->examination_type_id = $validated['examination_type_id']; $entranceExamination->direction_id = $validated['direction_id']; @@ -92,6 +101,17 @@ class EntranceExaminationController extends Controller $entranceExamination->scores = $validated['scores']; $entranceExamination->position = $validated['position']; $entranceExamination->subject_type_id = $validated['subject_type_id']; + + Log::channel('app') + ->warning( + 'UPDATE вступ. испытания {entranceExamination} - user {user}', + [ + 'user' => Auth::user()->name, + 'entranceExamination' => $entranceExamination->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); $entranceExamination->save(); return redirect()->route('entrance_examinations.index'); @@ -99,6 +119,15 @@ class EntranceExaminationController extends Controller public function destroy(EntranceExamination $entranceExamination): RedirectResponse { + Log::channel('app') + ->critical( + 'DELETE вступ. испытания {entranceExamination} - user {user}', + [ + 'user' => Auth::user()->name, + 'entranceExamination' => $entranceExamination->name, + 'data' => $entranceExamination->toArray(), + ] + ); $entranceExamination->delete(); return redirect()->route('entrance_examinations.index'); } diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php index f4e535d..87d31a3 100644 --- a/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php +++ b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php @@ -18,8 +18,38 @@ class StoreEntranceExaminationRequest extends FormRequest 'examination_type_id' => 'required|numeric|int|max:1000', 'subject_id' => 'required|numeric|int|max:1000', 'subject_type_id' => 'required|numeric|int|max:1000', - 'scores' => 'required|numeric|int|max:1000', + 'scores' => 'required|numeric|int|max:100', 'position' => 'required|numeric|int|max:1000', ]; } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'direction_id.required' => 'Поле позиция обязательно.', + 'direction_id.int' => 'Позиция должно быть целым числом.', + 'direction_id.numeric' => 'Позиция должно быть числом.', + 'direction_id.max' => 'Позиция не должен быть больше :max', + 'examination_type_id.required' => 'Поле позиция обязательно.', + 'examination_type_id.int' => 'Позиция должно быть целым числом.', + 'examination_type_id.numeric' => 'Позиция должно быть числом.', + 'examination_type_id.max' => 'Позиция не должен быть больше :max', + 'subject_id.required' => 'Поле позиция обязательно.', + 'subject_id.int' => 'Позиция должно быть целым числом.', + 'subject_id.numeric' => 'Позиция должно быть числом.', + 'subject_id.max' => 'Позиция не должен быть больше :max', + 'subject_type_id.required' => 'Поле позиция обязательно.', + 'subject_type_id.int' => 'Позиция должно быть целым числом.', + 'subject_type_id.numeric' => 'Позиция должно быть числом.', + 'subject_type_id.max' => 'Позиция не должен быть больше :max', + 'scores.required' => 'Поле позиция обязательно.', + 'scores.int' => 'Позиция должно быть целым числом.', + 'scores.numeric' => 'Позиция должно быть числом.', + 'scores.max' => 'Позиция не должен быть больше :max', + ]; + } } diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php index 883f336..4c46a9d 100644 --- a/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php @@ -18,8 +18,38 @@ class UpdateEntranceExaminationRequest extends FormRequest 'examination_type_id' => 'required|numeric|int|max:1000', 'subject_id' => 'required|numeric|int|max:1000', 'subject_type_id' => 'required|numeric|int|max:1000', - 'scores' => 'required|numeric|int|max:1000', + 'scores' => 'required|numeric|int|max:100', 'position' => 'required|numeric|int|max:1000', ]; } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'direction_id.required' => 'Поле позиция обязательно.', + 'direction_id.int' => 'Позиция должно быть целым числом.', + 'direction_id.numeric' => 'Позиция должно быть числом.', + 'direction_id.max' => 'Позиция не должен быть больше :max', + 'examination_type_id.required' => 'Поле позиция обязательно.', + 'examination_type_id.int' => 'Позиция должно быть целым числом.', + 'examination_type_id.numeric' => 'Позиция должно быть числом.', + 'examination_type_id.max' => 'Позиция не должен быть больше :max', + 'subject_id.required' => 'Поле позиция обязательно.', + 'subject_id.int' => 'Позиция должно быть целым числом.', + 'subject_id.numeric' => 'Позиция должно быть числом.', + 'subject_id.max' => 'Позиция не должен быть больше :max', + 'subject_type_id.required' => 'Поле позиция обязательно.', + 'subject_type_id.int' => 'Позиция должно быть целым числом.', + 'subject_type_id.numeric' => 'Позиция должно быть числом.', + 'subject_type_id.max' => 'Позиция не должен быть больше :max', + 'scores.required' => 'Поле позиция обязательно.', + 'scores.int' => 'Позиция должно быть целым числом.', + 'scores.numeric' => 'Позиция должно быть числом.', + 'scores.max' => 'Позиция не должен быть больше :max', + ]; + } } diff --git a/lang/ru/tooltips.php b/lang/ru/tooltips.php index 6c2baba..a0ebaaf 100644 --- a/lang/ru/tooltips.php +++ b/lang/ru/tooltips.php @@ -33,6 +33,7 @@ return [ 'subject_type_id' => 'Поле "Тип Предмета" указывает на привязку вступительного испытания к типу предмету', 'scores' => 'Поле "Кол-во баллов" указывает на привязку вступительного испытания к Кол-ву баллов', 'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте', + 'direction_id' => 'Поле "Направление подготовки" указывает на привязку вступительного испытания к направлению подготовки', ], 'educational_institutions' => [ 'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте', diff --git a/resources/views/admin/catalog/direction/entrance_examination/create.blade.php b/resources/views/admin/catalog/direction/entrance_examination/create.blade.php index 8165235..9a3b95d 100644 --- a/resources/views/admin/catalog/direction/entrance_examination/create.blade.php +++ b/resources/views/admin/catalog/direction/entrance_examination/create.blade.php @@ -1,54 +1,88 @@ +@php use App\Helpers\PositionHelper; @endphp @extends('layouts.admin_layout') @section('content') @auth()