12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
36
app/Http/Resources/CategoryResource.php
Normal file
36
app/Http/Resources/CategoryResource.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CategoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'legacy' => [
|
||||
'portal' => $this->legacy_portal,
|
||||
'id' => $this->legacy_id,
|
||||
],
|
||||
'portal' => $this->portal?->value,
|
||||
'is_active' => $this->is_active,
|
||||
'translations' => $this->whenLoaded('translations', fn () => $this->translations
|
||||
->mapWithKeys(fn ($translation) => [
|
||||
$translation->locale => [
|
||||
'name' => $translation->name,
|
||||
'slug' => $translation->slug,
|
||||
'description' => $translation->description,
|
||||
],
|
||||
])
|
||||
->all()),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue