update deploy
This commit is contained in:
38
app/Http/Resources/CategoryResource.php
Normal file
38
app/Http/Resources/CategoryResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Category
|
||||
*/
|
||||
class CategoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'slug' => $this->slug,
|
||||
'label' => $this->label,
|
||||
'desc' => $this->desc,
|
||||
'image' => $this->image,
|
||||
'meta_title' => $this->meta_title,
|
||||
'meta_description' => $this->meta_description,
|
||||
'courses_count' => $this->whenCounted('courses'),
|
||||
// Mega menu kartında gösterilecek kurslar (menu_order 1-3)
|
||||
'menu_courses' => $this->whenLoaded('menuCourses', fn () => $this->menuCourses->map(fn ($c) => [
|
||||
'title' => $c->title,
|
||||
'slug' => $c->slug,
|
||||
])
|
||||
),
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'updated_at' => $this->updated_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user