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') }}