1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Resources\Json\JsonResource;
- class AreaResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- $model = $this->resource;
- if(!empty($model)){
- return [
- 'id' => $model->id,
- 'name' => $model->name,
- 'admin_id' => $model->admin_id ?? 1,
- 'area_fence' => $model->area_fence,
- 'area_centre' => $model->area_centre,
- 'area_fushe_fence' => $model->area_fushe_fence,
- 'area_radius' => $model->area_radius,
- 'customer_service_time' => $model->customer_service_time,
- 'customer_service_phone' => $model->customer_service_phone,
- 'status' => (bool)$model->status,
- 'created_at' => (string)$model->created_at,
- 'updated_at' => (string)$model->updated_at,
- 'areaSetting' => $model->areaSetting,
- 'merchant_id' => $model->merchant_id,
- 'merchant_data' => $model->merchantData,
- ];
- }else{
- return [];
- }
- }
- }
|