123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Http\Resources\App;
- use App\Models\Order;
- use Carbon\Carbon;
- use Illuminate\Http\Resources\Json\JsonResource;
- class OrderResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- $model = $this->resource;
- $data = [
- 'id' => $model->id,
- 'no' => $model->no,
- 'nickname' => ($model->users->nickname ?? '')."(".($model->users->truename ?? '').")",
- 'mobile' => $model->users->mobile ?? '',
- 'orders_status' => Order::$statusMaps[$model->status],
- 'bike_no' => $model->bike_no,
- 'start_use_bike_time' => Carbon::make($model->start_use_bike_time)->format('Y/m/d H:i:s'),
- 'end_use_bike_time' => $model->end_use_bike_time ? Carbon::make($model->end_use_bike_time)->format('Y/m/d H:i:s') : '',
- 'created_at' => date('Y/m/d H:i:s',strtotime($model->created_at))
- ];
- return $data;
- }
- }
|