From cfebf09a74db31fdb58a2a496b643ffa5e1a71a3 Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Thu, 1 Sep 2022 21:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Shop/Providers/ShopServiceProvider.php | 2 ++ beike/Shop/View/Components/NoData.php | 21 ++++++++++++++++++++ themes/default/category.blade.php | 14 ++++++++----- themes/default/components/no-data.blade.php | 4 ++++ themes/default/search.blade.php | 10 +++++++--- 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 beike/Shop/View/Components/NoData.php create mode 100644 themes/default/components/no-data.blade.php diff --git a/beike/Shop/Providers/ShopServiceProvider.php b/beike/Shop/Providers/ShopServiceProvider.php index 8ede2fc1..efa57edf 100644 --- a/beike/Shop/Providers/ShopServiceProvider.php +++ b/beike/Shop/Providers/ShopServiceProvider.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\ServiceProvider; use Beike\Shop\View\Components\Breadcrumb; use Beike\Shop\View\Components\AccountSidebar; +use Beike\Shop\View\Components\NoData; class ShopServiceProvider extends ServiceProvider { @@ -85,6 +86,7 @@ class ShopServiceProvider extends ServiceProvider { $this->loadViewComponentsAs('shop', [ 'sidebar' => AccountSidebar::class, + 'no-data' => NoData::class, 'alert' => Alert::class, 'breadcrumb' => Breadcrumb::class ]); diff --git a/beike/Shop/View/Components/NoData.php b/beike/Shop/View/Components/NoData.php new file mode 100644 index 00000000..36e94e99 --- /dev/null +++ b/beike/Shop/View/Components/NoData.php @@ -0,0 +1,21 @@ +text = $text ?: trans('common.no_data'); + } + + public function render() + { + return view('components.no-data'); + } +} diff --git a/themes/default/category.blade.php b/themes/default/category.blade.php index af0e48be..45883052 100644 --- a/themes/default/category.blade.php +++ b/themes/default/category.blade.php @@ -2,15 +2,19 @@ @section('body-class', 'page-categories') @section('content') -
+
- @foreach ($products as $product) -
@include('shared.product')
- @endforeach + @if (count($products)) + @foreach ($products as $product) +
@include('shared.product')
+ @endforeach + @else + + @endif
-
+
@endsection diff --git a/themes/default/components/no-data.blade.php b/themes/default/components/no-data.blade.php new file mode 100644 index 00000000..44ecd46f --- /dev/null +++ b/themes/default/components/no-data.blade.php @@ -0,0 +1,4 @@ +
+ +
{{ $text }}
+
\ No newline at end of file diff --git a/themes/default/search.blade.php b/themes/default/search.blade.php index 70ec2a36..392b1435 100644 --- a/themes/default/search.blade.php +++ b/themes/default/search.blade.php @@ -7,9 +7,13 @@
- @foreach ($items as $product) -
@include('shared.product')
- @endforeach + @if (count($products)) + @foreach ($products as $product) +
@include('shared.product')
+ @endforeach + @else + + @endif
{{ $products->links('shared/pagination/bootstrap-4') }}