model = new OpmMwHospital; } public static function new(): HospitalRepository { return new self(); } /** * 只查询消毒灭菌医院 (ds_region_id != 0) */ public function scopedQuery() { return parent::scopedQuery()->where('ds_region_id', '!=', 0); } /** * 获取医院列表(带数据权限) */ public function getListWithPermission(): \Illuminate\Database\Eloquent\Collection { return $this->scopedQuery() ->orderBy('id', 'desc') ->get(); } /** * 根据ID查找医院 * @throws EntityNotFoundException */ public function findOrFail(int $id): OpmMwHospital { $hospital = $this->scopedQuery()->find($id); if (!$hospital) { throw new EntityNotFoundException('医院不存在'); } return $hospital; } }