ParkingTransformer.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/8/5
  6. * Time: 2:44 PM
  7. */
  8. namespace App\Transformers;
  9. use App\Models\Parking;
  10. use League\Fractal\TransformerAbstract;
  11. class ParkingTransformer extends TransformerAbstract
  12. {
  13. public function transform(Parking $model)
  14. {
  15. if ($model->type == Parking::TYPE_NO_STOP_BIKE) {
  16. $iconPath = 'http://resource.weilaibike.com/ban-stop.png';
  17. $strokeColor = '#FF0000';
  18. $fillColor = '#FF000030';
  19. } else {
  20. $iconPath = 'http://resource.weilaibike.com/stop1.png';
  21. $strokeColor = '#FF00FF';
  22. $fillColor = '#FF00FF66';
  23. }
  24. return [
  25. 'name' => $model->name,
  26. 'centre' => array_merge([
  27. 'iconPath' => $iconPath,
  28. 'width' => 24,
  29. 'height' => 28,
  30. 'zIndex' => $model->id,
  31. 'id' => $model->id,
  32. 'type' => $model->type,
  33. ],$model->parking_centre),
  34. 'points' => $model->parking_fence,
  35. 'radius' => $model->parking_radius,
  36. 'type' => $model->type,
  37. 'type_text' => Parking::$typeMaps[$model->type],
  38. 'strokeWidth' => 4,
  39. 'strokeColor' => $strokeColor,
  40. 'fillColor' => $fillColor
  41. ];
  42. }
  43. }