Files
portal/app/Http/Resources/Event.php
2020-07-19 12:15:23 +02:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class Event extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => [
'type' => 'events',
'event_id' => $this->id,
'attributes' => [
'data' => [
'name' => $this->name,
'description' => $this->description,
'start_date' => $this->start_date,
'end_date' => $this->end_date,
'location' => $this->location,
'category' => [
'data' => [
'category_id' => $this->category_id
],
],
]
],
],
'links' => [
'self' => url('/events/'.$this->id),
]
];
}
}