123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- declare(strict_types=1);
- namespace App\Model\Arts;
- use App\Master\Enum\PassportEnum;
- use App\Model\Model;
- use Hyperf\Cache\Annotation\Cacheable;
- class UserModel extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var ?string
- */
- protected ?string $table = 'user';
- protected ?string $dateFormat = 'U';
- public bool $timestamps = false;
- /**
- * 默认查询字段
- *
- * @var array|string[]
- */
- public array $select = [
- '*'
- ];
- protected int $is_status_search = 1;// 默认使用 status = 1 筛选
- protected int $is_delete_search = 0;// 默认使用 is_delete = 0 筛选
- /**
- * 中间件中获取用户信息
- * @param int $user_id
- * @return array
- */
- public function searchUserIdAttribute($query, $value, array $params): mixed
- {
- if (!isset($value)) {
- return $query;
- }
- return $query->where('user_id', $value);
- }
- public function authUserInfo(int $user_id)
- {
- return (new UserModel())->getDetail(params: ['id' => $user_id]);
- }
- }
|