No one can answer my question?
Jul 15, 2020
34
Level 10
Method Illuminate\Database\Eloquent\Collection::path does not exist.
I installed "cviebrock/eloquent-sluggable": "^4.8", and I want to add slug path of committees category.
I have a many committees in my menu
Look at my codes,
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="{{ $committee->committees->path() }}">{{ $committee->name }}</a>
@else
<a class="dropdown-item text-right"
href="{{ $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";
}
I get this error...
Method Illuminate\Database\Eloquent\Collection::path does not exist.
Level 29
@oxbir you are missing @foreach($row as $committee)
@foreach($row as $committee)
@foreach($committee->committees as $item)
@if(app()->getLocale() == 'fa')
<a class="dropdown-item text-right"
href="{{ $item->path() }}">{{ $committee->name }}</a>
@else
<a class="dropdown-item text-right"
href="{{$item->path() }}">{{ $committee->title_en }}</a>
@endif
@endforeach
@endforeach
1 like
Please or to participate in this conversation.





