*/ protected $fillable = [ 'store_id', 'store_code', 'store_name', 'store_type', 'store_level', 'industry_id', 'industry_detail_id', 'store_address', 'store_province', 'store_city', 'store_district', 'store_business_area', 'store_longitude', 'store_latitude', 'store_phone', 'status', 'create_time', 'update_time', ]; /** * 字段类型转换 * * @var array */ protected $casts = [ 'store_longitude' => 'float', 'store_latitude' => 'float', 'status' => 'int', 'create_time' => 'datetime', 'update_time' => 'datetime', ]; /** * 禁用 Laravel 默认时间戳 * * @var bool */ public $timestamps = false; /** * 根据门店名称查找门店 * * @param string $storeName 门店名称 * @return StoreRepository|null */ public function findByStoreName(string $storeName): ?StoreRepository { return $this->newQuery() ->where('store_name', $storeName) ->where('status', 0) // 只查询正常状态的门店 ->first(); } /** * 根据门店编码查找门店 * * @param string $storeCode 门店编码 * @return StoreRepository|null */ public function findByStoreCode(string $storeCode): ?StoreRepository { return $this->newQuery() ->where('store_code', $storeCode) ->first(); } }