Add (category)

This commit is contained in:
2023-11-20 02:50:16 +08:00
parent 36f0588ef8
commit 3ed6215b16
3 changed files with 12 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Providers;
use App\Views\Composers\ParentCategoryComposer;
use App\Views\Composers\CategoryComposer;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
@@ -26,7 +26,7 @@ public function register()
public function boot()
{
// Using class based composers...
View::composer('front.layouts.partials.nav', ParentCategoryComposer::class);
View::composer('front.layouts.partials.nav', CategoryComposer::class);
}
}

View File

@@ -5,10 +5,10 @@
use App\Models\Category;
use Illuminate\View\View;
class ParentCategoryComposer
class CategoryComposer
{
public function compose(View $view)
{
$view->with('parent_categories', Category::whereNull('parent_id')->get());
$view->with('categories', Category::get());
}
}

View File

@@ -1,5 +1,5 @@
<div class="w-full shadow-sm bg-black text-white">
<header class="container lh-1 py-3">
<header class="container-lg lh-1 py-3">
<div class="row d-block d-md-flex justify-content-center align-items-center">
<div class="col-12 col-md-5 col-lg-4 py-2 py-md-0 text-center text-md-start">
@@ -15,3 +15,10 @@
</div>
</header>
</div>
<div class="w-full bg-dark text-white d-none d-md-block">
<div class="container-lg text-center py-2">
@foreach ($categories as $category)
<a href="#" class="text-white mx-3 font-family-roboto-condensed text-uppercase">{{ $category->name }}</a>
@endforeach
</div>
</div>