Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern - Improved code organization and maintainability - Fixed minor bugs and inconsistencies
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Data\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AdditionalEducationCategoryPreviewResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'slug' => $this->slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Data\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AdditionalEducationCategoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'additionalEducations' => $this->additionalEducations
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Data\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AdditionalEducationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
'category' => $this->category->title,
|
||||
'directionAdditionalEducation' => new DirectionAdditionalEducationResource($this->category->direction),
|
||||
'target_group' => $this->target_group,
|
||||
'price' => $this->price,
|
||||
'qualification' => $this->qualification,
|
||||
'learning_time' => $this->learning_time,
|
||||
'form_education' => $this->form_education->getLabel(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Data\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DirectionAdditionalEducationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'slug' => $this->slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Loaders;
|
||||
|
||||
class AliasesLoader
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $aliases = [];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Loaders;
|
||||
|
||||
class MiddlewareLoader
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $middleware = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $middlewareGroups = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $routeMiddleware = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $middlewarePriority = [];
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Loaders;
|
||||
|
||||
class ProvidersLoader
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $providers = [];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Models;
|
||||
|
||||
use App\Ship\Enums\Education\FormEducation;
|
||||
use App\Ship\Models\Model;
|
||||
use App\Ship\Models\Seo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
|
||||
class AdditionalEducation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
'form_education' => FormEducation::class,
|
||||
];
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AdditionalEducationCategory::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
public function seo(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Seo::class, 'seoable');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Models;
|
||||
|
||||
use App\Ship\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class AdditionalEducationCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
public function scopeWithActivePrograms(Builder $query): Builder
|
||||
{
|
||||
return $query->with(['additionalEducations' => function ($query) {
|
||||
$query->where('is_active', true);
|
||||
}]);
|
||||
}
|
||||
|
||||
public function additionalEducations(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdditionalEducation::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
public function direction(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DirectionAdditionalEducation::class, 'dir_addit_educat_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Models;
|
||||
|
||||
use App\Ship\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class DirectionAdditionalEducation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
|
||||
public function additionalEducationCategories(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdditionalEducationCategory::class, 'dir_addit_educat_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Policies;
|
||||
|
||||
use App\Containers\User\Models\User;
|
||||
use App\Containers\AdditionalEducation\Models\AdditionalEducationCategory;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class AdditionalEducationCategoryPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->can('view_any_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('view_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->can('create_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('update_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('delete_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk delete.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('delete_any_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete.
|
||||
*/
|
||||
public function forceDelete(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('force_delete_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently bulk delete.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('force_delete_any_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore.
|
||||
*/
|
||||
public function restore(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('restore_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk restore.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->can('restore_any_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate.
|
||||
*/
|
||||
public function replicate(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
|
||||
{
|
||||
return $user->can('replicate_additional::education::category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->can('reorder_additional::education::category');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Policies;
|
||||
|
||||
use App\Containers\User\Models\User;
|
||||
use App\Containers\AdditionalEducation\Models\AdditionalEducation;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class AdditionalEducationPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->can('view_any_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('view_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->can('create_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('update_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('delete_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk delete.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('delete_any_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete.
|
||||
*/
|
||||
public function forceDelete(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('force_delete_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently bulk delete.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('force_delete_any_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore.
|
||||
*/
|
||||
public function restore(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('restore_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk restore.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->can('restore_any_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate.
|
||||
*/
|
||||
public function replicate(User $user, AdditionalEducation $additionalEducation): bool
|
||||
{
|
||||
return $user->can('replicate_additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->can('reorder_additional::education');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\Policies;
|
||||
|
||||
use App\Containers\User\Models\User;
|
||||
use App\Containers\AdditionalEducation\Models\DirectionAdditionalEducation;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class DirectionAdditionalEducationPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->can('view_any_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('view_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->can('create_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('update_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('delete_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk delete.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('delete_any_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete.
|
||||
*/
|
||||
public function forceDelete(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('force_delete_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently bulk delete.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->can('force_delete_any_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore.
|
||||
*/
|
||||
public function restore(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('restore_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk restore.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->can('restore_any_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate.
|
||||
*/
|
||||
public function replicate(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
|
||||
{
|
||||
return $user->can('replicate_direction::additional::education');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->can('reorder_direction::additional::education');
|
||||
}
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\AdditionalEducation\UI\WEB\Controllers;
|
||||
|
||||
use App\Containers\AdditionalEducation\Data\Resources\AdditionalEducationCategoryPreviewResource;
|
||||
use App\Containers\AdditionalEducation\Data\Resources\AdditionalEducationCategoryResource;
|
||||
use App\Containers\AdditionalEducation\Data\Resources\AdditionalEducationResource;
|
||||
use App\Containers\AdditionalEducation\Data\Resources\DirectionAdditionalEducationResource;
|
||||
use App\Containers\AdditionalEducation\Models\AdditionalEducation;
|
||||
use App\Containers\AdditionalEducation\Models\AdditionalEducationCategory;
|
||||
use App\Containers\AdditionalEducation\Models\DirectionAdditionalEducation;
|
||||
use App\Ship\Contracts\SeoServiceInterface;
|
||||
use App\Ship\Controllers\Controller;
|
||||
use App\Ship\Enums\CacheKeys;
|
||||
use App\Ship\Enums\Education\FormEducation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class ClientAdditionalEducationController extends Controller
|
||||
{
|
||||
public function __construct(readonly SeoServiceInterface $seoPageProvider){}
|
||||
|
||||
|
||||
public function index(Request $request): \Inertia\Response
|
||||
{
|
||||
$cacheKey = md5(serialize($request->all()));
|
||||
|
||||
// Основные данные (кешируются)
|
||||
$directionAdditionalEducations = Cache::remember(
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAMS_PREFIX->value . 'directions_' . $cacheKey,
|
||||
now()->addDay(),
|
||||
function () {
|
||||
return DirectionAdditionalEducationResource::collection(
|
||||
DirectionAdditionalEducation::query()
|
||||
->where('is_active', true)
|
||||
->whereHas('additionalEducationCategories', fn ($q) => $q->whereHas('additionalEducations'))
|
||||
->get()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$additionalEducations = Cache::remember(
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAMS_PREFIX->value . $cacheKey,
|
||||
now()->addDay(),
|
||||
function () use ($request) {
|
||||
$query = AdditionalEducationCategory::query()
|
||||
->has('additionalEducations')
|
||||
->withActivePrograms()
|
||||
->where('is_active', true);
|
||||
|
||||
if ($request->has('form')) {
|
||||
$formValue = FormEducation::fromName($request->form)->value;
|
||||
$query->whereHas('additionalEducations', fn ($q) => $q->where('form_education', $formValue))
|
||||
->with(['additionalEducations' => fn ($q) => $q->where('form_education', $formValue)]);
|
||||
}
|
||||
|
||||
if ($request->has('category')) {
|
||||
$slugs = is_array($request->category) ? $request->category : [$request->category];
|
||||
$query->whereIn('slug', $slugs);
|
||||
}
|
||||
|
||||
if ($request->has('direction')) {
|
||||
$query->whereHas('direction', fn($q) => $q->where('slug', $request->direction));
|
||||
}
|
||||
|
||||
return AdditionalEducationCategoryResource::collection($query->get());
|
||||
}
|
||||
);
|
||||
|
||||
$categories = Cache::remember(
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAMS_PREFIX->value . 'categories',
|
||||
now()->addWeek(),
|
||||
function () {
|
||||
return AdditionalEducationCategoryPreviewResource::collection(
|
||||
AdditionalEducationCategory::query()
|
||||
->where('is_active', true)
|
||||
->has('additionalEducations')
|
||||
->get()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Динамические данные (не кешируются)
|
||||
$categoriesContent = [];
|
||||
if ($request->category) {
|
||||
foreach ((array)$request->category as $item) {
|
||||
$categoriesContent[$item] = new AdditionalEducationCategoryResource(
|
||||
AdditionalEducationCategory::where('slug', $item)->first()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$forms_education = array_reduce(
|
||||
FormEducation::cases(),
|
||||
fn ($acc, $case) => $acc + [$case->name => $case->getLabel()],
|
||||
[]
|
||||
);
|
||||
|
||||
$filters = [
|
||||
'direction_filter' => [
|
||||
'type' => 'direction',
|
||||
'value' => $request->input('direction'),
|
||||
'param' => 'direction'
|
||||
],
|
||||
'form_education_filter' => [
|
||||
'type' => 'form',
|
||||
'value' => $request->input('form'),
|
||||
'param' => 'form'
|
||||
],
|
||||
'category_filter' => [
|
||||
'type' => 'category',
|
||||
'value' => $request->input('category'),
|
||||
'param' => 'category',
|
||||
'content' => $categoriesContent,
|
||||
],
|
||||
];
|
||||
|
||||
$seo = $this->seoPageProvider->getSeoForCurrentPage();
|
||||
|
||||
return Inertia::render('Client/Additional-educations/Index', compact(
|
||||
'directionAdditionalEducations',
|
||||
'additionalEducations',
|
||||
'filters',
|
||||
'forms_education',
|
||||
'categories',
|
||||
'seo'
|
||||
));
|
||||
}
|
||||
|
||||
public function show(string $slug): \Inertia\Response
|
||||
{
|
||||
$additionalEducationModel = Cache::remember(
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAM_PREFIX->value . $slug,
|
||||
now()->addDay(),
|
||||
fn() => AdditionalEducation::with('category.direction')->where('slug', $slug)->firstOrFail()
|
||||
);
|
||||
|
||||
$seo = Cache::remember(
|
||||
CacheKeys::ADDITIONAL_EDUCATIONAL_PROGRAM_PREFIX->value . 'seo_' . $slug,
|
||||
now()->addDay(),
|
||||
fn() => $this->seoPageProvider->getSeoForModel($additionalEducationModel)
|
||||
);
|
||||
|
||||
$settingsPage = request()->attributes->get('settings_page') ?? [];
|
||||
|
||||
if (array_key_exists('custom_form', $settingsPage)) {
|
||||
$form = $settingsPage['custom_form'];
|
||||
} else {
|
||||
$form = null;
|
||||
}
|
||||
|
||||
$additionalEducation = new AdditionalEducationResource($additionalEducationModel);
|
||||
|
||||
|
||||
return Inertia::render('Client/Additional-educations/Show', compact(
|
||||
'additionalEducation',
|
||||
'seo',
|
||||
'form',
|
||||
));
|
||||
}}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Containers\AdditionalEducation\UI\WEB\Controllers\ClientAdditionalEducationController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Route::middleware('access-check')->group(function () {
|
||||
Route::get('/additional-education/{slug}', [ClientAdditionalEducationController::class, 'show'])->name('client.additionalEducation.show');
|
||||
Route::get('/additional-education/', [ClientAdditionalEducationController::class, 'index'])->name('client.additionalEducation.index');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user