where('id|name|introduction', 'like', '%' . $where['name'] . '%'); } if (isset($where['type']) && $where['type'] != '' && ($data = self::setData($where['type']))) { $model = $model->where($data); } $count = $model->count(); $data = $model->page((int)$where['page'], (int)$where['limit'])->select(); foreach ($data as &$v) { $v['user'] = User::where('uid', $v['uid'])->value('nickname') . '/' . $v['uid']; } return compact('count', 'data'); } /** * 获取连表查询条件 * @param $type * @return array */ public static function setData($type) { switch ((int)$type) { case 1: $data = ['status' => 0]; break; case 2: $data = ['status' => 1]; break; case 3: $data = ['status' => 2]; break; }; return isset($data) ? $data : []; } /** * 获取门店信息 * @param int $id * @return array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getDetail($id) { $storeInfo = self::where('id', $id)->find(); $storeInfo['address'] = $storeInfo['address'] ? explode(',', $storeInfo['address']) : []; return $storeInfo; } }