AdminMerchantsResource.php 1001 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Models\AdminUser;
  4. use App\Traits\ResourceRolePermissionHelpers;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class AdminMerchantsResource extends JsonResource
  7. {
  8. use ResourceRolePermissionHelpers;
  9. /**
  10. * Transform the resource into an array.
  11. *
  12. * @param \Illuminate\Http\Request $request
  13. * @return array
  14. */
  15. public function toArray($request)
  16. {
  17. $model = $this->resource;
  18. if (!empty($model)) {
  19. return [
  20. 'id' => $model->id,
  21. 'account' => $model->admin_user['account'],
  22. 'name' => $model->name,
  23. 'phone' => $model->phone,
  24. 'email' => $model->email,
  25. 'proportion' => $model->proportion,
  26. 'status' => ($model->admin_user['status']==1) ? true : false,
  27. 'created_at' => (string)$model->created_at,
  28. ];
  29. } else {
  30. return [];
  31. }
  32. }
  33. }