AreaResource.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class AreaResource 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. if(!empty($model)){
  16. return [
  17. 'id' => $model->id,
  18. 'name' => $model->name,
  19. 'admin_id' => $model->admin_id ?? 1,
  20. 'area_fence' => $model->area_fence,
  21. 'area_centre' => $model->area_centre,
  22. 'area_fushe_fence' => $model->area_fushe_fence,
  23. 'area_radius' => $model->area_radius,
  24. 'customer_service_time' => $model->customer_service_time,
  25. 'customer_service_phone' => $model->customer_service_phone,
  26. 'status' => (bool)$model->status,
  27. 'created_at' => (string)$model->created_at,
  28. 'updated_at' => (string)$model->updated_at,
  29. 'areaSetting' => $model->areaSetting,
  30. 'merchant_id' => $model->merchant_id,
  31. 'merchant_data' => $model->merchantData,
  32. ];
  33. }else{
  34. return [];
  35. }
  36. }
  37. }