forked from aslan/applicant-site
prodV1 #2
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\admin\Catalog\Direction;
|
namespace App\Http\Controllers\admin\Catalog\Direction;
|
||||||
|
|
||||||
|
use App\Helpers\SlugHelper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\admin\Catalog\Direction\StoreEducationLevelRequest;
|
use App\Http\Requests\admin\Catalog\Direction\StoreEducationLevelRequest;
|
||||||
use App\Http\Requests\admin\Catalog\Direction\UpdateEducationLevelRequest;
|
use App\Http\Requests\admin\Catalog\Direction\UpdateEducationLevelRequest;
|
||||||
|
@ -10,6 +11,8 @@ 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\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class EducationLevelController extends Controller
|
class EducationLevelController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -27,18 +30,25 @@ class EducationLevelController extends Controller
|
||||||
public function store(StoreEducationLevelRequest $request): RedirectResponse
|
public function store(StoreEducationLevelRequest $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
|
$slug = SlugHelper::get($validated);
|
||||||
|
|
||||||
$level = new EducationLevel();
|
$level = new EducationLevel();
|
||||||
$level->name = $validated['name'];
|
$level->name = $validated['name'];
|
||||||
$level->description = $validated['description'];
|
$level->description = $validated['description'];
|
||||||
$level->slug = $validated['slug'];
|
$level->slug = $slug;
|
||||||
$level->save();
|
$level->save();
|
||||||
|
|
||||||
|
Log::channel('app')
|
||||||
|
->info(
|
||||||
|
'CREATE уровень образования {educationLevel} - user {user}',
|
||||||
|
['user' => Auth::user()->name, 'educationLevel' => $level->name, 'data' => $validated]
|
||||||
|
);
|
||||||
|
|
||||||
return redirect()->route('education_levels.index');
|
return redirect()->route('education_levels.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(
|
public function show(EducationLevel $educationLevel): View
|
||||||
EducationLevel $educationLevel
|
{
|
||||||
): View|Application|Factory|\Illuminate\Contracts\Foundation\Application {
|
|
||||||
$directions = $educationLevel->directions();
|
$directions = $educationLevel->directions();
|
||||||
return view(
|
return view(
|
||||||
'admin.catalog.direction.education_level.show',
|
'admin.catalog.direction.education_level.show',
|
||||||
|
@ -54,10 +64,22 @@ class EducationLevelController extends Controller
|
||||||
public function update(UpdateEducationLevelRequest $request, EducationLevel $educationLevel): RedirectResponse
|
public function update(UpdateEducationLevelRequest $request, EducationLevel $educationLevel): RedirectResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
|
$oldData = $educationLevel->toArray();
|
||||||
|
|
||||||
$educationLevel->name = $validated['name'];
|
$educationLevel->name = $validated['name'];
|
||||||
$educationLevel->description = $validated['description'];
|
$educationLevel->description = $validated['description'];
|
||||||
$educationLevel->slug = $validated['slug'];
|
$educationLevel->slug = $validated['slug'];
|
||||||
|
|
||||||
|
Log::channel('app')
|
||||||
|
->warning(
|
||||||
|
'UPDATE уровень образования {educationLevel} - user {user}',
|
||||||
|
[
|
||||||
|
'user' => Auth::user()->name,
|
||||||
|
'educationLevel' => $educationLevel->name,
|
||||||
|
'oldData' => $oldData,
|
||||||
|
'newData' => $validated
|
||||||
|
]
|
||||||
|
);
|
||||||
$educationLevel->save();
|
$educationLevel->save();
|
||||||
|
|
||||||
return redirect()->route('education_levels.index');
|
return redirect()->route('education_levels.index');
|
||||||
|
@ -66,8 +88,26 @@ class EducationLevelController extends Controller
|
||||||
public function destroy(EducationLevel $educationLevel)
|
public function destroy(EducationLevel $educationLevel)
|
||||||
{
|
{
|
||||||
if ($educationLevel->directions()->exists()) {
|
if ($educationLevel->directions()->exists()) {
|
||||||
|
Log::channel('app')
|
||||||
|
->error(
|
||||||
|
'NOT DELETE уровень образования {educationLevel} - user {user}',
|
||||||
|
[
|
||||||
|
'user' => Auth::user()->name,
|
||||||
|
'educationLevel' => $educationLevel->name,
|
||||||
|
'data' => $educationLevel->toArray(),
|
||||||
|
]
|
||||||
|
);
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
Log::channel('app')
|
||||||
|
->critical(
|
||||||
|
'DELETE уровень образования {educationLevel} - user {user}',
|
||||||
|
[
|
||||||
|
'user' => Auth::user()->name,
|
||||||
|
'educationLevel' => $educationLevel->name,
|
||||||
|
'data' => $educationLevel->toArray(),
|
||||||
|
]
|
||||||
|
);
|
||||||
$educationLevel->delete();
|
$educationLevel->delete();
|
||||||
return redirect()->route('education_levels.index');
|
return redirect()->route('education_levels.index');
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,21 @@ class StoreEducationLevelRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'required|string|max:255|unique:education_levels,name',
|
'name' => 'required|string|max:255|unique:education_levels,name',
|
||||||
'description' => 'string',
|
'description' => 'nullable|string',
|
||||||
'slug' => 'required|string|max:255|unique:education_levels,slug',
|
'slug' => 'nullable|string|max:255|unique:education_levels,slug',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name.required' => 'Поле название обязательно.',
|
||||||
|
'name.string' => 'Поле название должен быть строкой.',
|
||||||
|
'name.max' => 'Поле название не должен превышать :max символов.',
|
||||||
|
'name.unique' => 'Название уже занят.',
|
||||||
|
'description.string' => 'Поле описание должен быть строкой.',
|
||||||
|
'slug.string' => 'Поле URL должен быть строкой.',
|
||||||
|
'slug.max' => 'Поле URL не должен превышать :max символов.',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,21 @@ class UpdateEducationLevelRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => "required|string|max:255|unique:education_levels,name,{$this->education_level->id}",
|
'name' => "required|string|max:255|unique:education_levels,name,{$this->education_level->id}",
|
||||||
'description' => 'string',
|
'description' => 'nullable|string',
|
||||||
'slug' => "required|string|max:255|unique:education_levels,slug,{$this->education_level->id}",
|
'slug' => "required|string|max:255|unique:education_levels,slug,{$this->education_level->id}",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name.required' => 'Поле название обязательно.',
|
||||||
|
'name.string' => 'Поле название должен быть строкой.',
|
||||||
|
'name.max' => 'Поле название не должен превышать :max символов.',
|
||||||
|
'name.unique' => 'Название уже занят.',
|
||||||
|
'description.string' => 'Поле описание должен быть строкой.',
|
||||||
|
'slug.string' => 'Поле URL должен быть строкой.',
|
||||||
|
'slug.max' => 'Поле URL не должен превышать :max символов.',
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,9 @@ return [
|
||||||
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
|
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
|
||||||
'slug' => 'Поле "URL" нужно для отображения в браузере'
|
'slug' => 'Поле "URL" нужно для отображения в браузере'
|
||||||
],
|
],
|
||||||
|
'education_levels' => [
|
||||||
|
'name' => 'Поле "Название" должно быть уникальным для отображения на сайте',
|
||||||
|
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
|
||||||
|
'slug' => 'Поле "URL" нужно для отображения в браузере'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -4,39 +4,43 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1 class=""> Создать Уровень Образования</h1>
|
<h1 class=""> Создать Уровень Образования</h1>
|
||||||
{{ Form::open(['url' => route('education_levels.store'), 'method' => 'POST', 'class' => '']) }}
|
{{ Form::open(['url' => route('education_levels.store'), 'method' => 'POST', 'class' => 'needs-validation', 'novalidate']) }}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('name', 'Название') }}
|
{{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.name')]) }}
|
||||||
|
<span class="text-danger">*</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('name', '', ['class' => 'form-control']) }}
|
{{ Form::text('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.name'), 'required']) }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Поле "Название" обязательно!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('name') }}
|
{{ $errors->first('name') }}
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('description', 'Описание') }}
|
{{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.description')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('description', '', ['class' => 'form-control']) }}
|
{{ Form::text('description', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.description')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('description') }}
|
{{ $errors->first('description') }}
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('slug', 'URL') }}
|
{{ Form::label('slug', 'URL', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.slug')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('slug', '', ['class' => 'form-control']) }}
|
{{ Form::text('slug', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.education_levels.slug')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('slug') }}
|
{{ $errors->first('slug') }}
|
||||||
@endif
|
@endif
|
||||||
|
|
|
@ -5,39 +5,43 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1 class="">Езменить уровень образования</h1>
|
<h1 class="">Езменить уровень образования</h1>
|
||||||
{{ Form::open(['url' => route('education_levels.update', $educationLevel), 'method' => 'PATCH', 'class' => '']) }}
|
{{ Form::open(['url' => route('education_levels.update', $educationLevel), 'method' => 'PATCH', 'class' => 'needs-validation', 'novalidate']) }}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('name', 'Название') }}
|
{{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.name')]) }}
|
||||||
|
<span class="text-danger">*</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('name', $educationLevel->name, ['class' => 'form-control']) }}
|
{{ Form::text('name', $educationLevel->name, ['class' => 'form-control']) }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Поле "Название" обязательно!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('name') }}
|
{{ $errors->first('name') }}
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('description', 'Описание') }}
|
{{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.description')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('description', $educationLevel->description, ['class' => 'form-control']) }}
|
{{ Form::text('description', $educationLevel->description, ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.description')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('description') }}
|
{{ $errors->first('description') }}
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
{{ Form::label('slug', 'URL') }}
|
{{ Form::label('slug', 'URL', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.slug')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
{{ Form::text('slug', $educationLevel->slug, ['class' => 'form-control']) }}
|
{{ Form::text('slug', $educationLevel->slug, ['class' => 'form-control','data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.slug')]) }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="text-danger">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
{{ $errors->first('slug') }}
|
{{ $errors->first('slug') }}
|
||||||
@endif
|
@endif
|
||||||
|
|
Loading…
Reference in New Issue