123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- declare (strict_types=1);
- namespace app\dao\activity\coupon;
- use app\dao\BaseDao;
- use app\model\activity\coupon\StoreCouponUser;
- use app\model\user\User;
- class StoreCouponUserUserDao extends BaseDao
- {
- protected $alias = '';
- protected $join_alis = '';
-
- protected function setModel(): string
- {
- return StoreCouponUser::class;
- }
-
- public function joinModel(): string
- {
- return User::class;
- }
-
- public function getModel(string $alias = 'c', string $join_alias = 'u', $join = 'left')
- {
- $this->alias = $alias;
- $this->join_alis = $join_alias;
-
- $user = app()->make($this->joinModel());
- $table = $user->getName();
- return parent::getModel()->join($table . ' ' . $join_alias, $alias . '.uid = ' . $join_alias . '.uid', $join)->alias($alias);
- }
-
- public function sysPage(array $where, int $page, int $limit)
- {
- return $this->searchWhere($where)->page($page, $limit)->order('id desc')->select()->toArray();
- }
-
- public function sysCount(array $where)
- {
- return $this->searchWhere($where)->count();
- }
-
- public function searchWhere(array $where = [])
- {
- return $this->getModel()
- ->when($where['nickname'] != '', function ($query) use ($where) {
- $query->where('u.nickname', 'like', '%' . $where['nickname'] . '%');
- })->when($where['status'] != '', function ($query) use ($where) {
- $query->where('c.status', $where['status']);
- })->when($where['coupon_title'] != '', function ($query) use ($where) {
- $query->where('c.coupon_title', 'like', '%' . $where['coupon_title'] . '%');
- })->field('c.*,u.nickname');
- }
- }
|