2016-11-30 66 views
2

有了這個,我得到的物品數組:如何獲得他們沒有優先權的所有文章?

$unsortedArticles = $this->article->getAllCurentTranslation($language); 

我的文章和優先級之間的關係:

public function priority() 
    { 
     return $this->hasOne('App\Models\HomepagePriority','article_id','id'); 
    } 

因此,如何我現在可以返回的文章,但只是他們不物品數組優先??

回答

2

您想使用doesntHave()。喜歡的東西:

$articlesWithoutPriority = Aricle::doesntHave('priority')->get(); 

解決方案通過@Gerard Reches爲你的情況(假設getAllCurentTranslation($language)方法的最終用途->get()):

$unsortedArticles = $this->article() 
         ->doesntHave('priority') 
         ->getAllCurentTranslation($language); 
+0

但我怎麼可以使用它在這個$ unsortedArticles = $這個 - >物品─> getAllCurentTranslation($語言); ? – None

相關問題