3
我試圖從透視表中獲取數據:如何從數據透視表中獲取數據?
@foreach ($announcements as $index => $item)
{{dd($item->pivot->category->translate('en')->name)}}
{{dd($item->pivot->category->name)}}
@endforeach
我附截圖:
我試圖從透視表中獲取數據:如何從數據透視表中獲取數據?
@foreach ($announcements as $index => $item)
{{dd($item->pivot->category->translate('en')->name)}}
{{dd($item->pivot->category->name)}}
@endforeach
我附截圖:
您shouldnot提型號名稱:
{{dd($item->pivot->name)}}
如果items
和categories
有一個數據透視表item_category
,屬性爲name
然後,{{dd($item->pivot->name)}}
給出名稱屬性的值
這是否幫助您http://stackoverflow.com/questions/27434338/laravel-get-pivot-data-for-specific-many-to-many-relation –
發生什麼了? –