DriverLicenseModel.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Model\Arts;
  4. use App\Model\Model;
  5. use Hyperf\DbConnection\Db;
  6. use function Hyperf\Config\config;
  7. class DriverLicenseModel extends Model
  8. {
  9. /**
  10. * The table associated with the model.
  11. *
  12. * @var ?string
  13. */
  14. protected ?string $table = 'driver_license';
  15. protected ?string $dateFormat = 'U';
  16. public bool $timestamps = false;
  17. protected int $is_status_search = 1;// 默认使用 status = 1 筛选
  18. protected int $is_delete_search = 0;// 默认使用 is_delete = 0 筛选
  19. /**
  20. * 默认查询字段
  21. *
  22. * @var array|string[]
  23. */
  24. public array $select = [
  25. '*'
  26. ];
  27. /**
  28. * @param int $driver_id
  29. * @param array $params
  30. * @return int
  31. */
  32. public static function addEdit(int $driver_id, array $params = [])
  33. {
  34. if (!empty($driver_id)){
  35. $info = self::query()->where('driver_id', $driver_id)->first();
  36. }
  37. if (isset($info)){
  38. $params['update_time'] = time();
  39. if (!self::query()->where('id',$info['id'])->update($params)){
  40. return 0;
  41. }
  42. return $info['id'];
  43. }else{
  44. $params['driver_id'] = $driver_id;
  45. $params['create_time'] = time();
  46. return self::query()->insertGetId($params);
  47. }
  48. }
  49. }