hasMany('app\common\model\supplier\member\PlanAccess', 'plan_id', 'plan_id'); } /** * 获取启用的年卡列表 */ public function getEnabledPlans() { return $this->where(['status' => 1, 'is_default' =>0,'is_delete'=>0]) ->order(['sort' => 'asc', 'create_time' => 'desc']) ->select(); } /** * 获取启用的年卡列表(包含默认年卡) */ public function getEnabledPlansAll() { return $this->where(['status' => 1,'is_delete'=>0]) ->order(['sort' => 'asc', 'create_time' => 'desc']) ->select(); } /** * 获取详情 */ public static function detail($planId) { return (new static())->with(['plan_access'])->where('plan_id', '=', $planId)->find(); } /** * 获取列表 */ public function getList($data) { $model = $this; if (!empty($data['name'])) { $model = $model->where('name', 'like', '%' . $data['name'] . '%'); } if (isset($data['status']) && $data['status'] >= 0) { $model = $model->where('status', '=', $data['status']); } return $model->where('app_id', '=', $data['app_id']) ->order(['sort' => 'asc', 'create_time' => 'desc']) ->paginate($data); } }