diff --git a/beike/Admin/Http/Controllers/SettingController.php b/beike/Admin/Http/Controllers/SettingController.php index a54c16f2..ecb0eb57 100644 --- a/beike/Admin/Http/Controllers/SettingController.php +++ b/beike/Admin/Http/Controllers/SettingController.php @@ -40,7 +40,7 @@ class SettingController extends Controller ]; $data = [ - 'countries' => CountryRepo::all(), + 'countries' => CountryRepo::listEnabled(), 'currencies' => CurrencyRepo::listEnabled(), 'tax_address' => $tax_address, 'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(), diff --git a/beike/Repositories/CountryRepo.php b/beike/Repositories/CountryRepo.php index 9d9e7929..769f431b 100644 --- a/beike/Repositories/CountryRepo.php +++ b/beike/Repositories/CountryRepo.php @@ -13,6 +13,8 @@ namespace Beike\Repositories; use Beike\Models\Country; use Illuminate\Contracts\Pagination\LengthAwarePaginator; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Collection; class CountryRepo { @@ -100,6 +102,21 @@ class CountryRepo return $builder->paginate(20)->withQueryString(); } + + /** + * 获取已启用国家列表 + * @return Builder[]|Collection + */ + public static function listEnabled(): Collection|array + { + return Country::query()->where('status', true)->select('id', 'name')->get(); + } + + + /** + * 获取所有国家列表 + * @return Builder[]|Collection + */ public static function all() { return Country::query()->select('id', 'name')->get();