with = $with; parent::__construct(); } /** * 获取查询构建器 */ public function getQueryBuilder() { $query = parent::getQueryBuilder(); if (!empty($this->with)) { $query->with($this->with); } return $query; } /** * 查询详情页面数据 */ public function detail(\Dcat\Admin\Show $show): array { $result = $this->eloquentClass::with($this->with ?? []) ->where($this->getKeyName(), $show->getKey()) ->first(); if (!$result) { abort(404); } return $result->toArray(); } }