12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Http\Resources;
- use App\Models\RefundBalanceOrder;
- use Carbon\Carbon;
- use Illuminate\Http\Resources\Json\JsonResource;
- class RefundBalanceOrderResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- $model = $this->resource;
- $try_again = false;
- if($model->err_code == 'SYSTEMERROR' && $model->pay_status == RefundBalanceOrder::PAY_STATUS_NO){
- $try_again = true;
- }
- $data = [
- 'id' => $model->id,
- 'nickname' => $model->users->nickname ?? '',
- 'mobile' => $model->users->mobile ?? '',
- 'created_at' => Carbon::parse($model->created_at)->format('Y-m-d H:i:s'),
- 'area_id' => $model->area_id,
- 'area_name' => $model->area->name ?? '',
- 'admin_user_name' => $model->adminUser->name,
- 'pay_money' => $model->pay_money,
- 'pay_status' => $model->pay_status,
- 'no' => $model->no,
- 'try_again' => $try_again
- ];
- return $data;
- }
- }
|