unioil-loyalty-app/app/Http/Resources/StationLocatorResource.php

30 lines
826 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class StationLocatorResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$this->withoutWrapping();
return [
'station_uuid' => $this->station_uuid,
'name' => $this->description,
'address' => $this->address,
'longitude' => $this->longitude,
'latitude' => $this->latitude,
'stars' => round($this->average),
'favorite' => $this->favorite > 0 ? true : false,
];
}
}