3

I tried to get data from pivot table as:

@foreach ($announcements as $index => $item)
      {{dd($item->pivot->category->translate('en')->name)}}
      {{dd($item->pivot->category->name)}}
@endforeach

I attached screenshot:

enter image description here

Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43
SFSFSFSF
  • 47
  • 6

1 Answers1

1

You shouldnot mention the model name:

{{dd($item->pivot->name)}}

if items and categories has a pivot table item_category with attribute name then, {{dd($item->pivot->name)}} gives the value of name attribute

Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43