diff --git a/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php b/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php new file mode 100644 index 0000000..0423be8 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php @@ -0,0 +1,72 @@ +validated(); + + $type = new ExaminationType(); + $type->name = $validated['name']; + $type->description = $validated['description']; + $type->slug = $validated['slug']; + $type->position = $validated['position']; + $type->save(); + + return redirect()->route('examination_types.index'); + } + + public function show(ExaminationType $examinationType): View + { + return view('admin.catalog.direction.examination_type.show', compact('examinationType')); + } + + public function edit(ExaminationType $examinationType): View + { + return view('admin.catalog.direction.examination_type.edit', compact('examinationType')); + } + + public function update(UpdateExaminationTypeRequest $request, ExaminationType $examinationType): RedirectResponse + { + $validated = $request->validated(); + + $examinationType->name = $validated['name']; + $examinationType->description = $validated['description']; + $examinationType->slug = $validated['slug']; + $examinationType->position = $validated['position']; + $examinationType->save(); + + return redirect()->route('examination_types.index'); + } + + public function destroy(ExaminationType $examinationType): RedirectResponse + { + if ($examinationType->entranceExaminations()->exists()) { + return back(); + } + $examinationType->delete(); + return redirect()->route('examination_types.index'); + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php new file mode 100644 index 0000000..a094703 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php @@ -0,0 +1,23 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:examination_types,name', + 'description' => 'string', + 'slug' => 'required|string|max:255|unique:examination_types,slug', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php new file mode 100644 index 0000000..9f96463 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php @@ -0,0 +1,33 @@ + 'required|int|numeric|max:255', + 'description' => 'string', + 'slug' => [ + 'string', + 'required', + 'max:255', + "unique:examination_types,slug,{$this->examination_type->id}", + ], + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:examination_types,name,{$this->examination_type->id}", + ], + ]; + } +} diff --git a/app/Models/ExaminationType.php b/app/Models/ExaminationType.php new file mode 100644 index 0000000..f58bc48 --- /dev/null +++ b/app/Models/ExaminationType.php @@ -0,0 +1,25 @@ +hasMany('App\Models\EntranceExamination', 'examination_type_id'); + } +} diff --git a/database/factories/ExaminationTypeFactory.php b/database/factories/ExaminationTypeFactory.php new file mode 100644 index 0000000..0770812 --- /dev/null +++ b/database/factories/ExaminationTypeFactory.php @@ -0,0 +1,18 @@ + fake()->name(), + 'description' => fake()->text(), + 'slug' => fake()->slug(), + 'position' => fake()->randomDigit(), + ]; + } +} diff --git a/database/migrations/2024_02_15_075912_create_examination_types_table.php b/database/migrations/2024_02_15_075912_create_examination_types_table.php new file mode 100644 index 0000000..4613728 --- /dev/null +++ b/database/migrations/2024_02_15_075912_create_examination_types_table.php @@ -0,0 +1,25 @@ +id(); + $table->integer('position'); + $table->string('name'); + $table->text('description')->nullable(); + $table->string('slug'); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('examination_types'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index e33cb85..04e3826 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\ExaminationType; use App\Models\User; use Illuminate\Database\Seeder; @@ -26,6 +27,7 @@ class DatabaseSeeder extends Seeder DepartmentSeeder::class, EducationLevelSeeder::class, EducationFormSeeder::class, + ExaminationTypeSeeder::class, DirectionSeeder::class, ]); diff --git a/database/seeders/ExaminationTypeSeeder.php b/database/seeders/ExaminationTypeSeeder.php new file mode 100644 index 0000000..ad26ea3 --- /dev/null +++ b/database/seeders/ExaminationTypeSeeder.php @@ -0,0 +1,34 @@ +insert([ + [ + 'name' => 'ЕГЭ', + 'description' => 'Unified State Examination', + 'position' => '1', + 'slug' => 'USE', + ], + [ + 'name' => 'СПО', + 'description' => 'secondary vocational education', + 'position' => '2', + 'slug' => 'SVE', + ], + [ + 'name' => 'магитсратура', + 'description' => 'type magistracy', + 'position' => '3', + 'slug' => 'MAG', + ], + ]); + } +} diff --git a/resources/views/admin/catalog/direction/examination_type/create.blade.php b/resources/views/admin/catalog/direction/examination_type/create.blade.php new file mode 100644 index 0000000..1d6cef9 --- /dev/null +++ b/resources/views/admin/catalog/direction/examination_type/create.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.admin_layout') +@section('content') + @auth() +
+
+

Создать тип экзамена

+ {{ Form::open(['url' => route('examination_types.store'), 'method' => 'POST', 'class' => '']) }} +
+
+ {{ Form::label('name', 'Название') }} +
+
+ {{ Form::text('name', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('name') }} + @endif +
+ +
+ {{ Form::label('description', 'Описание') }} +
+
+ {{ Form::text('description', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+ +
+ {{ Form::label('slug', 'URL') }} +
+
+ {{ Form::text('slug', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('slug') }} + @endif +
+ +
+ {{ Form::label('position', 'Позиция') }} +
+
+ {{ Form::text('position', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('position') }} + @endif +
+ +
+ {{ Form::submit('Создать', ['class' => 'btn btn-primary']) }} +
+
+ {{ Form::close() }} +
+
+ @endauth +@endsection diff --git a/resources/views/admin/catalog/direction/examination_type/edit.blade.php b/resources/views/admin/catalog/direction/examination_type/edit.blade.php new file mode 100644 index 0000000..5998ef2 --- /dev/null +++ b/resources/views/admin/catalog/direction/examination_type/edit.blade.php @@ -0,0 +1,66 @@ +@extends('layouts.admin_layout') +@section('content') + + @auth() +
+
+

Изменить тип экзамена

+ {{ Form::open(['url' => route('examination_types.update', $examinationType), 'method' => 'PATCH', 'class' => '']) }} +
+
+ {{ Form::label('name', 'Название') }} +
+
+ {{ Form::text('name', $examinationType->name, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('name') }} + @endif +
+ +
+ {{ Form::label('description', 'Описание') }} +
+
+ {{ Form::text('description', $examinationType->description, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+ +
+ {{ Form::label('slug', 'URL') }} +
+
+ {{ Form::text('slug', $examinationType->slug, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('slug') }} + @endif +
+ +
+ {{ Form::label('position', 'Позиция') }} +
+
+ {{ Form::text('position', $examinationType->position, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('position') }} + @endif +
+ +
+ {{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }} +
+
+ {{ Form::close() }} +
+
+ @endauth +@endsection diff --git a/resources/views/admin/catalog/direction/examination_type/index.blade.php b/resources/views/admin/catalog/direction/examination_type/index.blade.php new file mode 100644 index 0000000..3cc2417 --- /dev/null +++ b/resources/views/admin/catalog/direction/examination_type/index.blade.php @@ -0,0 +1,41 @@ +@extends('layouts.admin_layout') +@section('content') +
+

Тип Экзамена

+
+ Создать тип экзамена +
+
+ + + + + + + + + + + + + @foreach($types as $type) + + + + + + + + @endforeach + +
ПозицияНазваниеОписаниеURLдействия
{{ $type->position }}{{ $type->name }}{{ Str::words($type->description, 10, '...') }}{{ $type->slug }} + редактировать + удалить +
+
+
+
+@endsection diff --git a/resources/views/admin/catalog/direction/examination_type/show.blade.php b/resources/views/admin/catalog/direction/examination_type/show.blade.php new file mode 100644 index 0000000..fa351f0 --- /dev/null +++ b/resources/views/admin/catalog/direction/examination_type/show.blade.php @@ -0,0 +1,17 @@ +@extends('layouts.admin_layout') +@section('content') + @auth() +
+

Название

+

{{ $educationForm->name }}

+

Описание

+

{{ $educationForm->description }}

+

URL

+

{{ $educationForm->slug }}

+

Направления

+ @foreach($directions as $direction) +

{{ $direction->name }}

+ @endforeach +
+ @endauth +@endsection diff --git a/resources/views/layouts/admin_layout.blade.php b/resources/views/layouts/admin_layout.blade.php index d8a6c53..140dd25 100644 --- a/resources/views/layouts/admin_layout.blade.php +++ b/resources/views/layouts/admin_layout.blade.php @@ -58,6 +58,7 @@
  • Направления
  • Уровни образования
  • Формы образования
  • +
  • Тип Экзаменов
  • @yield('content')
    diff --git a/routes/admin.php b/routes/admin.php index 9dd4ea3..520742d 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -4,6 +4,7 @@ use App\Http\Controllers\admin\AdmissionController; use App\Http\Controllers\admin\Catalog\DepartmentController; use App\Http\Controllers\admin\Catalog\Direction\EducationFormController; use App\Http\Controllers\admin\Catalog\Direction\EducationLevelController; +use App\Http\Controllers\admin\Catalog\Direction\ExaminationTypeController; use App\Http\Controllers\admin\Catalog\DirectionController; use App\Http\Controllers\admin\Catalog\EducationalInstitutionController; use App\Http\Controllers\admin\Catalog\FacultyController; @@ -41,6 +42,9 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { Route::resource('/education_forms', EducationFormController::class) ->scoped(['education_form' => 'slug']); + Route::resource('/examination_types', ExaminationTypeController::class) + ->scoped(['examination_type' => 'slug']); + Route::resources([ '/documents' => DocumentController::class, '/users' => UserController::class,