123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Resources\Json\JsonResource;
- class ParkingResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- $model = $this->resource;
- return [
- 'id' => $model->id,
- 'area_id' => $model->area_id,
- 'name' => $model->name,
- 'area_name' => $model->area->name,
- 'max_number' => $model->max_number,
- 'parking_fence' => json_decode($model->parking_fence),
- 'parking_centre' => $model->parking_centre,
- 'parking_radius' => $model->parking_radius,
- 'type' => $model->type,
- 'status' => (bool)$model->status,
- 'created_at' => (string)$model->created_at,
- 'updated_at' => (string)$model->updated_at
- ];
- }
- }
|