first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?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')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user