50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Course;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/**
|
|
* @mixin Course
|
|
*/
|
|
class CourseResource extends JsonResource
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'category_id' => $this->category_id,
|
|
'category' => new CategoryResource($this->whenLoaded('category')),
|
|
'slug' => $this->slug,
|
|
'title' => $this->title,
|
|
'sub' => $this->sub,
|
|
'desc' => $this->desc,
|
|
'long_desc' => $this->long_desc,
|
|
'duration' => $this->duration,
|
|
'students' => $this->students,
|
|
'rating' => $this->rating,
|
|
'badge' => $this->badge?->value,
|
|
'badge_label' => $this->badge?->label(),
|
|
'image' => $this->image,
|
|
'price' => $this->price,
|
|
'includes' => $this->includes,
|
|
'requirements' => $this->requirements,
|
|
'meta_title' => $this->meta_title,
|
|
'meta_description' => $this->meta_description,
|
|
'scope' => $this->scope,
|
|
'standard' => $this->standard,
|
|
'language' => $this->language,
|
|
'location' => $this->location,
|
|
'blocks' => CourseBlockResource::collection($this->whenLoaded('blocks')),
|
|
'schedules' => CourseScheduleResource::collection($this->whenLoaded('schedules')),
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|