31 lines
847 B
PHP
31 lines
847 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Http\Resources;
|
||
|
|
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
|
|
||
|
|
class AttractionResource extends JsonResource
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Transform the resource into an array.
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function toArray(Request $request): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'id' => $this->id,
|
||
|
|
'name' => $this->name,
|
||
|
|
'description' => $this->description,
|
||
|
|
'latitude' => (float) $this->latitude,
|
||
|
|
'longitude' => (float) $this->longitude,
|
||
|
|
'category' => $this->category,
|
||
|
|
'source' => $this->source,
|
||
|
|
'rating' => $this->rating ? (float) $this->rating : null,
|
||
|
|
'image_url' => $this->image_url,
|
||
|
|
'city' => new CityResource($this->whenLoaded('city')),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|