ParkingResource.php 963 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class ParkingResource extends JsonResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @return array
  11. */
  12. public function toArray($request)
  13. {
  14. $model = $this->resource;
  15. return [
  16. 'id' => $model->id,
  17. 'area_id' => $model->area_id,
  18. 'name' => $model->name,
  19. 'area_name' => $model->area->name,
  20. 'max_number' => $model->max_number,
  21. 'parking_fence' => json_decode($model->parking_fence),
  22. 'parking_centre' => $model->parking_centre,
  23. 'parking_radius' => $model->parking_radius,
  24. 'type' => $model->type,
  25. 'status' => (bool)$model->status,
  26. 'created_at' => (string)$model->created_at,
  27. 'updated_at' => (string)$model->updated_at
  28. ];
  29. }
  30. }