禁用的国家不显示

This commit is contained in:
Edward Yang 2022-08-31 11:29:42 +08:00
parent 167ee5c1df
commit f58bb18fe7
2 changed files with 18 additions and 1 deletions

View File

@ -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(),

View File

@ -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();