1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- declare(strict_types=1);
- namespace App\Model\Arts;
- use App\Model\Model;
- use Hyperf\DbConnection\Db;
- use function Hyperf\Config\config;
- class DriverLicenseModel extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var ?string
- */
- protected ?string $table = 'driver_license';
- protected ?string $dateFormat = 'U';
- public bool $timestamps = false;
- protected int $is_status_search = 1;// 默认使用 status = 1 筛选
- protected int $is_delete_search = 0;// 默认使用 is_delete = 0 筛选
- /**
- * 默认查询字段
- *
- * @var array|string[]
- */
- public array $select = [
- '*'
- ];
- /**
- * @param int $driver_id
- * @param array $params
- * @return int
- */
- public static function addEdit(int $driver_id, array $params = [])
- {
- if (!empty($driver_id)){
- $info = self::query()->where('driver_id', $driver_id)->first();
- }
- if (isset($info)){
- $params['update_time'] = time();
- if (!self::query()->where('id',$info['id'])->update($params)){
- return 0;
- }
- return $info['id'];
- }else{
- $params['driver_id'] = $driver_id;
- $params['create_time'] = time();
- return self::query()->insertGetId($params);
- }
- }
- }
|