user(); } /** * @comment 用户id * @return int */ public function userId(): int { return $this->user()->id; } /** * 当前仓库ID * * @return int */ public function getDrugstoreId(): int { if (!$this->drugstore_id) { $this->drugstore_id = $this->getStore()->drugstore_id; } return $this->drugstore_id; } /** * 当前仓库 * * @return Drugstore */ public function getDrugstore(): Drugstore { $this->drugstore = Drugstore::where('id', $this->getDrugstoreId())->first(); if (!$this->drugstore) { json_error('药房信息获取失败'); } return $this->drugstore; } /** * 获取门店ID * * @return int */ public function getStoreId(): int { if (!$this->store_id) { $this->store_id = (int)request()->input('store_id'); } return $this->store_id; } /** * 获取门店 * * @return Store */ public function getStore(): Store { $this->store = Store::where('id', $this->getStoreId())->first(); if (!$this->store) { json_error('门店信息获取失败'); } return $this->store; } }