12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- declare(strict_types=1);
- namespace App\Model\Arts;
- use App\Master\Enum\RedisKeyEnum;
- use App\Model\Model;
- use App\Utils\RedisUtil;
- use Hyperf\DbConnection\Db;
- class DriverMessageReadModel extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var ?string
- */
- protected ?string $table = 'driver_message_read';
- protected ?string $dateFormat = 'U';
- public bool $timestamps = false;
- protected int $is_status_search = 0;// 是否使用 1=是 0=否 默认使用 status = 1 筛选
- protected int $is_delete_search = 0;// 是否使用 1=是 0=否 默认使用 is_delete = 0 筛选
- /**
- * 默认查询字段
- *
- * @var array|string[]
- */
- public array $select = [
- '*'
- ];
- public function searchDriverIdAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->where('driver_id', $value);
- }
- public function searchIsReadAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->where('is_read', $value);
- }
- public function searchIdAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->where('id', $value);
- }
- public static function add(array $params)
- {
- $insert = array_merge($params,[
- 'status' => 1,
- 'create_time' => time()
- ]);
- return self::query()->insertGetId($insert);
- }
- public static function edit(int $id, array $params)
- {
- unset($params['id']);
- $insert = array_merge($params,[
- 'update_time' => time()
- ]);
- $query = self::query()->where('id',$id);
- return $query->update($insert);
- }
- }
|