'string', 'postage' => 'string', 'free_shipping_threshold' => 'string', 'is_pickup' => 'integer', 'province_id' => 'integer', 'city_id' => 'integer', 'county_id' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 关联医生药房绑定表 */ public function DoctorPharmacy(): HasMany { return $this->hasMany(DoctorPharmacy::class, 'pharmacy_id', 'pharmacy_id'); } /** * 获取单条有效药房数据 */ public static function getValidPharmacy(int|string $pharmacyId): ?self { return self::where([ 'pharmacy_id' => (string) $pharmacyId, 'status' => 1, ])->first(); } /** * 获取单条药房信息 */ public static function getOne(array $params, array $fields = ['*']): ?self { return self::where($params)->first($fields); } /** * 获取药房列表 */ public static function getList(array $params = [], array $fields = ['*']): Collection { return self::where($params)->get($fields); } /** * 分页查询药房 */ public static function getPage(array $params, array $fields = ['*'], ?int $page = null, ?int $per_page = 10): array { $raw = self::where($params)->paginate($per_page, $fields, 'page', $page); return [ 'current_page' => $raw->currentPage(), 'total' => $raw->total(), 'data' => $raw->items(), 'per_page' => $raw->perPage(), 'last_page' => $raw->lastPage(), ]; } }