后台配置每页显示数量

This commit is contained in:
Edward Yang 2022-12-16 14:17:32 +08:00
parent 40f8cf8c9c
commit fe16241f26
23 changed files with 45 additions and 31 deletions

View File

@ -28,7 +28,7 @@ class PageRepo
'description'
])->orderByDesc('updated_at');
return $builder->paginate();
return $builder->paginate(perPage());
}

View File

@ -542,7 +542,7 @@ if (!function_exists('sub_string')) {
* @param mixed $builder
* @return string|string[]|null
*/
function to_sql($builder)
function to_sql($builder): array|string|null
{
$sql = $builder->toSql();
foreach ($builder->getBindings() as $binding) {
@ -575,7 +575,7 @@ function create_directories($directoryPath)
* @param $hookValue
* @return mixed
*/
function hook_filter($hookKey, $hookValue)
function hook_filter($hookKey, $hookValue): mixed
{
return Eventy::filter($hookKey, $hookValue);
}
@ -587,7 +587,7 @@ function hook_filter($hookKey, $hookValue)
* @param $hookValue
* @return mixed
*/
function hook_action($hookKey, $hookValue)
function hook_action($hookKey, $hookValue): mixed
{
Eventy::action($hookKey, $hookValue);
}
@ -624,7 +624,7 @@ function add_action($hook, $callback, int $priority = 20, int $arguments = 1)
*
* @return bool
*/
function installed()
function installed(): bool
{
return file_exists(storage_path('installed'));
}
@ -634,7 +634,7 @@ function installed()
*
* @return bool
*/
function is_mobile()
function is_mobile(): bool
{
return (new \Jenssegers\Agent\Agent())->isMobile();
}
@ -645,7 +645,7 @@ function is_mobile()
*
* @return bool
*/
function is_secure()
function is_secure(): bool
{
if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
@ -660,3 +660,14 @@ function is_secure()
}
return false;
}
/**
* 每页商品显示数量
*
* @return int
*/
function perPage(): int
{
return (int)system_setting('base.product_per_page', 20);
}

View File

@ -95,7 +95,7 @@ class BrandRepo
public static function list($filters): LengthAwarePaginator
{
$builder = self::getBuilder($filters);
return $builder->paginate(10)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}

View File

@ -99,7 +99,7 @@ class CountryRepo
$builder->where('countries.status', $data['status']);
}
return $builder->paginate(20)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}

View File

@ -81,7 +81,7 @@ class CustomerRepo
public static function list($data): LengthAwarePaginator
{
$builder = self::getListBuilder($data);
return $builder->paginate(20)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}
@ -170,7 +170,7 @@ class CustomerRepo
$builder = $customer->wishlists()
->whereHas('product');
return $builder->with('product.description')->paginate(20);
return $builder->with('product.description')->paginate(perPage());
}
/**

View File

@ -44,7 +44,7 @@ class OrderRepo
public static function getListByCustomer($customer): LengthAwarePaginator
{
$builder = self::getListBuilder(['customer' => $customer])->orderByDesc('created_at');
return $builder->paginate();
return $builder->paginate(perPage());
}
@ -69,7 +69,7 @@ class OrderRepo
public static function filterOrders(array $filters = []): LengthAwarePaginator
{
$builder = self::getListBuilder($filters)->orderByDesc('created_at');
return $builder->paginate();
return $builder->paginate(perPage());
}

View File

@ -48,7 +48,7 @@ class ProductRepo
public static function getProductsByCategory($categoryId): AnonymousResourceCollection
{
$builder = self::getBuilder(['category_id' => $categoryId, 'active' => 1]);
$products = $builder->with('inCurrentWishlist')->paginate(20);
$products = $builder->with('inCurrentWishlist')->paginate(perPage());
return ProductSimple::collection($products);
}
@ -138,7 +138,7 @@ class ProductRepo
public static function list($data = [])
{
return self::getBuilder($data)->paginate($data['per_page'] ?? 20);
return self::getBuilder($data)->paginate($data['per_page'] ?? perPage());
}
public static function autocomplete($name)

View File

@ -121,7 +121,7 @@ class RmaRepo
}
$builder->orderBy('id', 'DESC');
return $builder->paginate(10)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}
/**

View File

@ -84,7 +84,7 @@ class UserRepo
$builder->where('admin_users.active', $data['active']);
}
return $builder->paginate(20)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}
}

View File

@ -97,7 +97,7 @@ class ZoneRepo
$builder->where('zones.status', $data['status']);
}
return $builder->paginate(20)->withQueryString();
return $builder->paginate(perPage())->withQueryString();
}
/**

View File

@ -27,7 +27,7 @@ class BrandController extends Controller
'description',
'inCurrentWishlist'
])
->paginate(20);
->paginate(perPage());
$data = [
'brand' => $brand,

View File

@ -35,7 +35,10 @@ class ProductController extends Controller
public function search(Request $request)
{
$keyword = $request->get('keyword');
$products = ProductRepo::getBuilder(['keyword' => $keyword])->where('active', true)->paginate();
$products = ProductRepo::getBuilder(['keyword' => $keyword])
->where('active', true)
->paginate(perPage())
->withQueryString();
$data = [
'products' => $products,

View File

@ -31,7 +31,7 @@ class MenusController extends Controller
$products = ProductRepo::getBuilder(['active' => 1])
->whereHas('master_sku')
->with('inCurrentWishlist')
->paginate(40);
->paginate(perPage());
$data = [
'products' => $products,

View File

@ -69,7 +69,7 @@
<div class="help-text font-size-12 lh-base">{{ __('admin/setting.admin_name_info') }}</div>
</x-admin-form-input>
<x-admin-form-input name="product_perpage" title="{{ __('admin/setting.product_perpage') }}" required value="{{ old('product_perpage', system_setting('base.product_perpage', 20)) }}">
<x-admin-form-input name="product_per_page" title="{{ __('admin/setting.product_per_page') }}" required value="{{ old('product_per_page', system_setting('base.product_per_page', 20)) }}">
</x-admin-form-input>
{{-- <x-admin-form-select title="模版主题" name="theme" :value="old('theme', system_setting('base.theme', 'default'))" :options="$themes">

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Home-Editor',
'design_footer_index' => 'Fußzeilen-Editor',
'design_menu_index' => 'Navigationseditor',
'product_perpage' => 'Die Anzahl der auf jeder Seite angezeigten Produkte',
'product_per_page' => 'Die Anzahl der auf jeder Seite angezeigten Produkte',
'basic_settings' => 'Grundeinstellungen',
'store_settings' => 'Store-Einstellungen',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Design Builder',
'design_footer_index' => 'Design Footer',
'design_menu_index' => 'Design Menu',
'product_perpage' => 'The number of products displayed on each page',
'product_per_page' => 'The Number of Per Page',
'basic_settings' => 'Basic Settings',
'store_settings' => 'Store Settings',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Editor de inicio',
'design_footer_index' => 'editor de pie de página',
'design_menu_index' => 'Editor de navegación',
'product_perpage' => 'El número de productos mostrados en cada página',
'product_per_page' => 'El número de productos mostrados en cada página',
'basic_settings' => 'configuraciones básicas',
'store_settings' => 'configuración de la tienda',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Éditeur d\'accueil',
'design_footer_index' => 'éditeur de pied de page',
'design_menu_index' => 'Éditeur de navigation',
'product_perpage' => 'Le nombre de produits affichés sur chaque page',
'product_per_page' => 'Le nombre de produits affichés sur chaque page',
'basic_settings' => 'paramètres de base',
'store_settings' => 'paramètres du magasin',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Casa Editore',
'design_footer_index' => 'editor footer',
'design_menu_index' => 'Editor di navigazione',
'product_perpage' => 'Il numero di prodotti visualizzati su ogni pagina',
'product_per_page' => 'Il numero di prodotti visualizzati su ogni pagina',
'basic_settings' => 'impostazioni di base',
'store_settings' => 'impostazioni negozio',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'ホーム エディター',
'design_footer_index' => 'フッター エディター',
'design_menu_index' => 'ナビゲーション エディター',
'product_perpage' => '各ページに表示される商品の数',
'product_per_page' => '各ページに表示される商品の数',
'basic_settings' => '基本設定',
'store_settings' => 'ストア設定',

View File

@ -16,7 +16,7 @@ return [
'design_index' => 'Домашний редактор',
'design_footer_index' => 'Редактор нижнего колонтитула',
'design_menu_index' => 'Редактор навигации',
'product_perpage' => 'Количество товаров, отображаемых на каждой странице',
'product_per_page' => 'Количество товаров, отображаемых на каждой странице',
'basic_settings' => 'Базовые настройки',
'store_settings' => 'Настройки магазина',

View File

@ -16,7 +16,7 @@ return [
'design_index' => '首页编辑器',
'design_footer_index' => '页尾编辑器',
'design_menu_index' => '导航编辑器',
'product_perpage' => '每页显示商品个数',
'product_per_page' => '每页显示',
'basic_settings' => '基础设置',
'store_settings' => '商店设置',

View File

@ -16,7 +16,7 @@ return [
'design_index' => '首頁編輯器',
'design_footer_index' => '頁尾編輯器',
'design_menu_index' => '導航編輯器',
'product_perpage' => '每頁顯示商品個數',
'product_per_page' => '每頁顯示商品個數',
'basic_settings' => '基礎設置',
'store_settings' => '商店設置',