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() +
Позиция | +Название | +Описание | +URL | +действия | ++ |
---|---|---|---|---|---|
{{ $type->position }} | +{{ $type->name }} | +{{ Str::words($type->description, 10, '...') }} | +{{ $type->slug }} | ++ редактировать + удалить + | +
{{ $educationForm->name }}
+{{ $educationForm->description }}
+{{ $educationForm->slug }}
+