WalletCollection.php 893 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Resources\V2;
  3. use Carbon\Carbon;
  4. use Illuminate\Http\Resources\Json\ResourceCollection;
  5. class WalletCollection extends ResourceCollection
  6. {
  7. public function toArray($request)
  8. {
  9. return [
  10. 'data' => $this->collection->map(function($data) {
  11. return [
  12. 'amount' => format_price ($data->amount) ,
  13. 'payment_method' => ucwords(str_replace('_', ' ', $data->payment_method)),
  14. 'approval_string' => $data->offline_payment ? ($data->approval == 1 ? "Approved" : "Decliend") : "N/A",
  15. 'date' => Carbon::createFromTimestamp(strtotime($data->created_at))->format('d-m-Y'),
  16. ];
  17. })
  18. ];
  19. }
  20. public function with($request)
  21. {
  22. return [
  23. 'success' => true,
  24. 'status' => 200
  25. ];
  26. }
  27. }