123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- declare(strict_types=1);
- namespace App\Model\Arts;
- use App\Master\Framework\Library\Tencent\TencentIm;
- use App\Model\Model;
- use Hyperf\DbConnection\Db;
- class LiveRoomBlackModel extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var ?string
- */
- protected ?string $table = 'live_room_black';
- 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 searchRoomNoAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->where('room_no', $value);
- }
- public function searchUserIdAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->where('user_id', $value);
- }
- public function searchKeywordAttribute($query, $value, array $params): mixed
- {
- if (empty($value)) {
- return $query;
- }
- return $query->withWhereHas('user',function ($query) use($value) {
- $query->where('nickname','like',"%{$value}%");
- });
- }
- // 用户信息
- public function user()
- {
- return $this->hasOne(UserModel::class, 'id', 'user_id');
- }
- }
|