2017-01-12 23:40:35 -08:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Location;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
|
|
|
|
class LocationsTransformer
|
|
|
|
{
|
|
|
|
|
2017-01-13 01:43:51 -08:00
|
|
|
public function transformLocations (Collection $locations)
|
2017-01-12 23:40:35 -08:00
|
|
|
{
|
|
|
|
$locations_array = array();
|
|
|
|
$locations_array[] = self::transformLocation($locations);
|
2017-01-13 01:44:47 -08:00
|
|
|
return $locations_array;
|
2017-01-12 23:40:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function transformLocation(Location $location = null)
|
|
|
|
{
|
|
|
|
if ($location) {
|
|
|
|
$locations_array[] = [
|
|
|
|
'id' => e($location->id),
|
2017-01-13 00:13:57 -08:00
|
|
|
'name' => e($location->name),
|
|
|
|
'address' => e($location->address),
|
|
|
|
'city' => e($location->city),
|
|
|
|
'state' => e($location->state),
|
|
|
|
'country' => e($location->country),
|
2017-01-12 23:40:35 -08:00
|
|
|
];
|
|
|
|
return $locations_array;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|