UserBikeOperate.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Log;
  6. class UserBikeOperate extends Model
  7. {
  8. protected $guarded = [];
  9. const STATUS_OK = 1;
  10. const STATUS_PAUSE = 0;
  11. public static $statusMaps = [
  12. self::STATUS_OK => '正常',
  13. self::STATUS_PAUSE => '暂停'
  14. ];
  15. const TYPE_NULL = 0;
  16. const TYPE_BILL_BIKE = 1;
  17. const TYPE_OPEN_BIKE = 2;
  18. const TYPE_CLONE_BIKE = 3;
  19. public static $typeMaps = [
  20. self::TYPE_NULL => '未知',
  21. self::TYPE_BILL_BIKE => '寻车',
  22. self::TYPE_OPEN_BIKE => '开锁',
  23. self::TYPE_CLONE_BIKE => '关锁'
  24. ];
  25. public static function log($type, $bike_no, $user_id, $lat, $lng)
  26. {
  27. $data = [
  28. 'name' => self::$typeMaps[$type],
  29. 'type' => $type,
  30. 'bike_no' => $bike_no,
  31. 'user_id' => $user_id,
  32. 'latitude' => $lat,
  33. 'longitude' => $lng,
  34. ];
  35. self::create($data);
  36. }
  37. }