2017-01-10 49 views
0

在Jessenger laravel MongoDB的包,我有兩個型號乘客laravel Mongodb多對多的關係?

屬於一對多的關係

物業

應用

我想獲取所有的屬性在它的複雜性。 現在我正在做這件事。

$ application = Application :: with('properties') - > find($ application - > _ id);

它返回對單個應用程序的唯一屬性。

我想要的是獲取所有應用程序的所有屬性。

回答

1

find是使用主鍵查找記錄。您將需要使用get來查找具有匹配數據的所有記錄。試試這個:

$applications = Application::with('properties')->get(); 
dd($applications); 

退房的文檔:https://laravel.com/docs/5.3/queries#retrieving-results

+0

有限制,由於我使用liberary型號https://github.com/jenssegers/laravel-mongodb/blob/8d06ac5342b00705e2dd7a78ea84368a3c7ed697/tests /RelationsTest.php#L325我只能使用它定義的方法,。, –

+0

有什麼限制? –

+0

我們不能在laravel模型上使用所有的函數,我只能實現由Jessenger模型重寫的函數。 –