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:
F4ilji
2025-05-12 08:47:43 +05:00
parent 76deaf75f3
commit c01016a154
620 changed files with 16218 additions and 6073 deletions
@@ -0,0 +1,26 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class FullInfoPersonResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'details' => new PersonDetailResource($this->whenLoaded('userDetail')),
'departments_work' => PersonDepartmentsWorkResource::collection($this->whenLoaded('departments_work')),
'departments_teach' => PersonDepartmentsTeachResource::collection($this->whenLoaded('departments_teach')),
'divisions_works' => PersonDivisionsWorkResource::collection($this->whenLoaded('divisions')),
'faculties_works' => PersonFacultiesWorkResource::collection($this->whenLoaded('faculties'))
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDepartmentPreviewResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'academicTitle' => $this->userDetail->academicTitle ?? null,
'contactPhone' => $this->pivot->service_phone,
'contactEmail' => $this->pivot->service_email,
'cabinet' => $this->pivot->cabinet,
'photo' => $this->userDetail->photo ?? null,
'position' => $this->pivot->position,
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDepartmentTeachPreviewResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'academicTitle' => $this->userDetail->academicTitle ?? null,
'contactPhone' => $this->pivot->service_phone,
'contactEmail' => $this->pivot->service_email,
'cabinet' => $this->pivot->cabinet,
'photo' => $this->userDetail->photo ?? null,
'position' => $this->pivot->teaching_position,
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDepartmentsTeachResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id_department' => $this->id,
'title' => $this->title,
'faculty_title' => $this->faculty->title,
'slug' => $this->slug,
'faculty_slug' => $this->faculty->slug,
'position' => $this->pivot->teaching_position,
];
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDepartmentsWorkResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id_department' => $this->id,
'title' => $this->title,
'faculty_title' => $this->faculty->title,
'slug' => $this->slug,
'faculty_slug' => $this->faculty->slug,
'position' => $this->pivot->position,
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDetailResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return parent::toArray($request);
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDivisionPreviewResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'academicTitle' => $this->userDetail->academicTitle,
'contactPhone' => $this->pivot->service_phone,
'contactEmail' => $this->pivot->service_email,
'cabinet' => $this->pivot->cabinet,
'photo' => $this->userDetail->photo,
'administrativePosition' => $this->pivot->administrativePosition,
'sort' => $this->pivot->sort,
'details' => $this->userDetail,
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonDivisionsWorkResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id_division' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'position' => $this->pivot->administrativePosition,
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonFacultiesWorkResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id_faculty' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'position' => $this->pivot->position,
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Containers\User\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
class PersonFacultyPreviewResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'academicTitle' => $this->userDetail->academicTitle,
'contactPhone' => $this->pivot->service_phone,
'contactEmail' => $this->pivot->service_email,
'cabinet' => $this->pivot->cabinet,
'photo' => $this->userDetail->photo,
'position' => $this->pivot->position,
];
}
}