ما یه دسته داریم به نام کمیته ها
که از جدول دسته بندی میاد نمایش میدهد
AppServiceProvider.php
public function register()
{
Schema::defaultStringLength(191);
view()->composer('*', function($view) {
$view->with('catCommittee', Category::where('parent_id',16)->get());
});
}
header.blade.php
<li class="nav-item dropdown has-mega-menu position-static">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
aria-haspopup="true" aria-expanded="false">
{{ __('message.menu.committees') }}
</a>
<div class="dropdown-menu w-100">
<div class="px-0 container">
<div class="row">
@if (isset($catCommittee))
@foreach($catCommittee->split($catCommittee->count()/1) as $row)
<div class="col-md-4">
@foreach($row as $committee)
@if(app()->getLocale() == 'fa')
<a class="dropdown-item text-right"
href="https://roocket.ir/{{ $committee->committees->path() }}">{{ $committee->name }}</a>
@else
<a class="dropdown-item text-right"
href="https://roocket.ir/{{ $committee->committees->path() }}">{{ $committee->title_en }}</a>
@endif
@endforeach
</div>
@endforeach
@endif
</div>
</div>
</div>
</li>
Category.php
public function committees()
{
return $this->belongsToMany(Committee::class,'category_committee','category_id','committee_id');
}
Committee.php
public function path()
{
$locale = app()->getLocale();
return "/$locale/committee/$this->slug";
}
Method Illuminate\Database\Eloquent\Collection::path does not exist.
شاید پاسخ شما همینجا باشد