changes
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\EducationalGroups;
|
||||
|
||||
use App\Containers\Schedule\Models\EducationalGroup;
|
||||
|
||||
class CreateEducationalGroupAction
|
||||
{
|
||||
public function run(array $data): EducationalGroup
|
||||
{
|
||||
return EducationalGroup::create($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\EducationalGroups;
|
||||
|
||||
use App\Containers\Schedule\Models\EducationalGroup;
|
||||
|
||||
class DeleteEducationalGroupAction
|
||||
{
|
||||
public function run(EducationalGroup $group): bool
|
||||
{
|
||||
return $group->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\EducationalGroups;
|
||||
|
||||
use App\Containers\Schedule\Models\EducationalGroup;
|
||||
use App\Ship\Enums\Education\FormEducation;
|
||||
use App\Containers\InstituteStructure\Models\Faculty;
|
||||
|
||||
class ListEducationalGroupsAction
|
||||
{
|
||||
public function run(array $filters = []): array
|
||||
{
|
||||
$query = EducationalGroup::with(['faculty']);
|
||||
|
||||
// Фильтр по факультету
|
||||
if (!empty($filters['faculty_id'])) {
|
||||
$query->where('faculty_id', $filters['faculty_id']);
|
||||
}
|
||||
|
||||
// Фильтр по форме обучения
|
||||
if (!empty($filters['education_form_id'])) {
|
||||
$query->where('education_form_id', $filters['education_form_id']);
|
||||
}
|
||||
|
||||
// Поиск по названию группы
|
||||
if (!empty($filters['search'])) {
|
||||
$query->where('title', 'like', '%' . $filters['search'] . '%');
|
||||
}
|
||||
|
||||
$groups = $query->orderBy('title')->paginate(20)->withQueryString();
|
||||
|
||||
return [
|
||||
'groups' => $groups,
|
||||
'filters' => $filters,
|
||||
'faculties' => Faculty::orderBy('title')->get(['id', 'title']),
|
||||
'educationForms' => array_map(fn($form) => [
|
||||
'value' => $form->value,
|
||||
'label' => $form->getLabel(),
|
||||
'color' => $form->getColor(),
|
||||
'name' => $form->name,
|
||||
], FormEducation::cases()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\EducationalGroups;
|
||||
|
||||
use App\Containers\Schedule\Models\EducationalGroup;
|
||||
|
||||
class UpdateEducationalGroupAction
|
||||
{
|
||||
public function run(EducationalGroup $group, array $data): EducationalGroup
|
||||
{
|
||||
$group->update($data);
|
||||
return $group->fresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user