1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- class Parking extends Model
- {
- //
- use ModelHelpers;
- // 停车点中心点(redis)
- const REDIS_STOP_BIKE_SITES_TAG = 'stop_bike_sites';
- const REDIS_BAN_STOP_BIKE_SITE_TAG = 'stop_ban_bike_sites';
- // 正确示例
- const TYPE_STOP_BIKE = 2;
- const TYPE_NO_STOP_BIKE = 1;
- public static $typeMaps = [
- self::TYPE_STOP_BIKE => '停车区',
- self::TYPE_NO_STOP_BIKE => '禁停区'
- ];
- // 错误示例
- // protected $parkingType = [1 => '禁停区', 2 => '停车区'];
- const STATUS_OK = 1;
- const STATUS_NO = 0;
- public static $statusMaps = [
- self::STATUS_NO => '禁用',
- self::STATUS_OK => '启用',
- ];
- protected $fillable = ['area_id', 'name', 'max_number', 'parking_fence', 'parking_centre', 'description', 'parking_radius', 'type', 'status'];
- public function getParkingCentreAttribute($value)
- {
- return toGaodeCentreData($value);
- }
- public function getWxParkingCentreAttribute()
- {
- return $this->attributes['parking_centre'];
- }
- public function getWxParkingFenceAttribute($value)
- {
- return $this->attributes['parking_fence'];
- }
- public function getParkingFenceAttribute($value)
- {
- return toGaodeFenceData($value);
- }
- public function setParkingCentreAttribute($value)
- {
- $this->attributes['parking_centre'] = latToLatitude($value);
- }
- public function setParkingFenceAttribute($value)
- {
- $this->attributes['parking_fence'] = latToLatitude($value);
- }
- public function area()
- {
- return $this->belongsTo(Area::class, 'area_id', 'id');
- }
- }
|