Compare commits

..

No commits in common. "d0a9dcae2b8e1b3ad0006220852fa532f3a0d2c8" and "86597ad075e2fff3c57cea75531c095e04cff24f" have entirely different histories.

7 changed files with 13 additions and 68 deletions

View File

@ -1,10 +0,0 @@
<?php
namespace App\Enums;
enum ExaminationTypeEnum: int
{
case Ege = 1;
case Spo = 2;
case Magistracy = 3;
}

View File

@ -2,7 +2,6 @@
namespace App\Http\Controllers\admin\Catalog;
use App\Enums\ExaminationTypeEnum;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreDirectionRequest;
use App\Http\Requests\admin\Catalog\UpdateDirectionRequest;
@ -38,8 +37,7 @@ class DirectionController extends Controller
$subjects = Subject::pluck('name', 'id');
$subjectTypes = SubjectType::pluck('name', 'id');
$directionProfiles = DirectionProfile::pluck('name', 'id');
return view(
'admin.catalog.direction.create',
return view('admin.catalog.direction.create',
compact(
'departments',
'levels',
@ -100,18 +98,18 @@ class DirectionController extends Controller
$ege = $direction
->entranceExaminations
->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value)
->where('examination_type_id', '=', '1')
->sortBy('position')
->pluck('scores', 'subject_id');
$spo = $direction
->entranceExaminations->where('examination_type_id', '=', ExaminationTypeEnum::Spo->value)
->entranceExaminations->where('examination_type_id', '=', '2')
->sortBy('position')
->pluck('scores', 'subject_id');
$magistracy = $direction
->entranceExaminations
->where('examination_type_id', '=', ExaminationTypeEnum::Magistracy->value)
->where('examination_type_id', '=', '3')
->sortBy('position')
->pluck('scores', 'subject_id');
@ -138,8 +136,7 @@ class DirectionController extends Controller
$subjects = Subject::pluck('name', 'id');
$subjectTypes = SubjectType::pluck('name', 'id');
$directionProfiles = DirectionProfile::pluck('name', 'id');
return view(
'admin.catalog.direction.edit',
return view('admin.catalog.direction.edit',
compact(
'direction',
'departments',
@ -206,45 +203,10 @@ class DirectionController extends Controller
if ($direction->entranceExaminations()->exists()) {
return back();
}
$direction->directionProfiles()->detach();
if ($direction->places()->exists()) {
return back();
}
$direction->delete();
return redirect()->route('directions.index');
}
public function duplication(Direction $direction): RedirectResponse
{
$now = now()->toAtomString();
$newDirection = new Direction();
$newDirection->name = $direction->name;
$newDirection->full_name = "{$direction->code} {$direction->name}";
$newDirection->description = $direction->description;
$newDirection->position = $direction->position;
$newDirection->slug = "{$direction->slug} {$now}";
$newDirection->code = $direction->code;
$newDirection->education_level_id = $direction->education_level_id;
$newDirection->education_form_id = $direction->education_form_id;
$newDirection->department_id = $direction->department_id;
$newDirection->budget_places = $direction->budget_places;
$newDirection->quota = $direction->quota;
$newDirection->paid_places = $direction->paid_places;
$newDirection->cost_paid_place = $direction->cost_paid_place;
$newDirection->period = $direction->period;
$newDirection->save();
foreach ($direction->entranceExaminations as $entranceExamination) {
$newEntranceExamination = new EntranceExamination();
$newEntranceExamination->examination_type_id = $entranceExamination->examination_type_id;
$newEntranceExamination->direction_id = $newDirection->id;
$newEntranceExamination->subject_id = $entranceExamination->subject_id;
$newEntranceExamination->scores = $entranceExamination->scores;
$newEntranceExamination->position = $entranceExamination->position;
$newEntranceExamination->subject_type_id = $entranceExamination->subject_type_id;
$newEntranceExamination->save();
}
$newDirection->directionProfiles()->attach($direction->directionProfiles);
return redirect()->route('directions.index');
}
}

View File

@ -18,7 +18,7 @@ class StoreDirectionRequest extends FormRequest
'name' => 'required|string|max:255',
'description' => 'string',
'slug' => 'required|string|max:255|unique:directions,slug',
'code' => 'required|string|max:255',
'code' => 'required|string|max:255|unique:directions,code',
'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000',
'department_id' => 'required|numeric|int|max:1000',

View File

@ -19,7 +19,7 @@ class UpdateDirectionRequest extends FormRequest
'name' => 'required|string|max:255',
'description' => 'string',
'slug' => "required|string|max:255|unique:directions,slug,{$this->direction->id}",
'code' => "required|string|max:255",
'code' => "required|string|max:255|unique:directions,code,{$this->direction->id}",
'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000',
'department_id' => 'required|numeric|int|max:1000',

View File

@ -2,7 +2,6 @@
namespace Database\Seeders;
use App\Enums\ExaminationTypeEnum;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
@ -15,19 +14,19 @@ class ExaminationTypeSeeder extends Seeder
[
'name' => 'ЕГЭ',
'description' => 'Unified State Examination',
'position' => ExaminationTypeEnum::Ege->value,
'position' => '1',
'slug' => 'USE',
],
[
'name' => 'СПО',
'description' => 'secondary vocational education',
'position' => ExaminationTypeEnum::Spo->value,
'position' => '2',
'slug' => 'SVE',
],
[
'name' => 'магитсратура',
'description' => 'type magistracy',
'position' => ExaminationTypeEnum::Magistracy->value,
'position' => '3',
'slug' => 'MAG',
],
]);

View File

@ -32,9 +32,6 @@
<td>
<a href="{{ route("directions.edit", $direction) }}"
class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="post"
href="{{ route('directions.duplication', $direction->id) }}"
class="btn btn-warning">Дублировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('directions.destroy', $direction) }}"
class="btn btn-danger">удалить</a>

View File

@ -32,9 +32,6 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
Route::resource('/directions', DirectionController::class)
->scoped(['direction' => 'slug']);
Route::post('/directions.duplication/{direction}', [DirectionController::class, 'duplication'])
->name('directions.duplication');
Route::resource('/departments', DepartmentController::class)
->scoped(['department' => 'slug']);
Route::resource('/faculties', FacultyController::class)