2014-01-22 64 views
2

我正在嘗試從我的laravel中獲取多對多關係的項目。Laravel多對多/從db中選擇與另一個不相關的條目

我有帖子和標籤。

所以有可能是有標籤還沒有連接到帖子。我怎樣才能從數據庫中獲得這些信息?

$tags = Tag::with('posts')->where('posts', [])->get(); 
$tags = Tag::with('posts')->where('posts', '')->get(); 
$tags = Tag::with('posts')->wherePosts('')->get(); 
$tags = Tag::with('posts')->wherePosts([])->get(); 

那些不起作用。有沒有其他方法?如果我返回

$tags = Tag::with('posts')->get(); 

我可以看到那些帖子= []但我現在不知道如何獲取它們。

謝謝。

回答

相關問題