// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\model\activity\lottery; use crmeb\basic\BaseModel; use crmeb\traits\ModelTrait; use think\Model; /** * * Class LuckPrizeDao * @package app\model\activity\lottery */ class LuckPrize extends BaseModel { use ModelTrait; /** * 数据表主键 * @var string */ protected $pk = 'id'; /** * 模型名称 * @var string */ protected $name = 'luck_prize'; /** * 关联抽奖 * @return \think\model\relation\HasOne */ public function lottery() { return $this->hasOne(LuckLottery::class, 'id', 'lottery_id'); } /** * 抽奖id搜索器 * @param $query Model * @param $value */ public function searchLotteryIdAttr($query, $value) { if ($value) $query->where('lottery_id', $value); } /** * 奖品类型搜索器 * @param $query Model * @param $value */ public function searchTypeAttr($query, $value) { if ($value) $query->where('type', $value); } /** * 状态搜索器 * @param $query Model * @param $value */ public function searchStatusAttr($query, $value) { if ($value !== '') $query->where('status', $value); } /** * 是否删除搜索器 * @param $query Model * @param $value */ public function searchIsDelAttr($query, $value) { if ($value !== '') $query->where('is_del', $value); } }