ProfitResource.php 695 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Models\WalletLog;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class ProfitResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @return array
  12. */
  13. public function toArray($request)
  14. {
  15. $model = $this->resource;
  16. return [
  17. 'created_at' => date('Y-m-d H:i:s',strtotime($model->created_at)),
  18. 'nickname' => $model->users->nickname ?? '',
  19. 'mobile' => $model->users->mobile ?? '',
  20. 'type' => WalletLog::$typeMaps[$model->type],
  21. 'money' => $model->money
  22. ];
  23. }
  24. }