DepositCardTransformer.php 936 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. *
  4. *
  5. * @category xxx
  6. * @package PSR
  7. * @subpackage Documentation\API
  8. * @author xxx <xxx@xxx.com>
  9. * @license GPL https://xxx.com
  10. * @link https://xxx.com
  11. * @ctime: 2020/4/30 16:12
  12. */
  13. namespace App\Transformers;
  14. use App\Models\DepositCard;
  15. use League\Fractal\TransformerAbstract;
  16. class DepositCardTransformer extends TransformerAbstract
  17. {
  18. public function transform(DepositCard $depositCard)
  19. {
  20. return [
  21. 'id' => $depositCard->id,
  22. 'name' => $depositCard->name,
  23. 'price' => $depositCard->price,
  24. 'is_discount_name' => DepositCard::$discountMaps[$depositCard->is_discount],//($depositCard->is_discount),
  25. 'is_discount' => $depositCard->is_discount,//($depositCard->is_discount),
  26. 'effective_days' => $depositCard->effective_days,
  27. 'discount' => bcdiv($depositCard->discount, 10, 1),
  28. ];
  29. }
  30. }