2021-11-19 22:58:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Course\Resources;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
2022-01-02 12:32:57 +01:00
|
|
|
/**
|
|
|
|
* @mixin \App\Course\Models\CourseMember
|
|
|
|
*/
|
2021-11-19 22:58:27 +01:00
|
|
|
class CourseResource extends JsonResource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
2022-03-11 20:19:17 +01:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
*
|
2021-11-19 22:58:27 +01:00
|
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => $this->id,
|
2021-11-20 01:43:20 +01:00
|
|
|
'organizer' => $this->organizer,
|
|
|
|
'event_name' => $this->event_name,
|
|
|
|
'completed_at_human' => Carbon::parse($this->completed_at)->format('d.m.Y'),
|
|
|
|
'completed_at' => $this->completed_at,
|
|
|
|
'course_name' => $this->course->name,
|
|
|
|
'course_id' => $this->course->id,
|
2021-11-19 22:58:27 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|