12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/8/5
- * Time: 2:44 PM
- */
- namespace App\Transformers;
- use App\Models\Parking;
- use League\Fractal\TransformerAbstract;
- class ParkingTransformer extends TransformerAbstract
- {
- public function transform(Parking $model)
- {
- if ($model->type == Parking::TYPE_NO_STOP_BIKE) {
- $iconPath = 'http://resource.weilaibike.com/ban-stop.png';
- $strokeColor = '#FF0000';
- $fillColor = '#FF000030';
- } else {
- $iconPath = 'http://resource.weilaibike.com/stop1.png';
- $strokeColor = '#FF00FF';
- $fillColor = '#FF00FF66';
- }
- return [
- 'name' => $model->name,
- 'centre' => array_merge([
- 'iconPath' => $iconPath,
- 'width' => 24,
- 'height' => 28,
- 'zIndex' => $model->id,
- 'id' => $model->id,
- 'type' => $model->type,
- ],$model->parking_centre),
- 'points' => $model->parking_fence,
- 'radius' => $model->parking_radius,
- 'type' => $model->type,
- 'type_text' => Parking::$typeMaps[$model->type],
- 'strokeWidth' => 4,
- 'strokeColor' => $strokeColor,
- 'fillColor' => $fillColor
- ];
- }
- }
|