Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何获得他们没有优先权的所有文章?_Laravel_Laravel 5_Laravel 5.2 - Fatal编程技术网

Laravel 如何获得他们没有优先权的所有文章?

Laravel 如何获得他们没有优先权的所有文章?,laravel,laravel-5,laravel-5.2,Laravel,Laravel 5,Laravel 5.2,有了这些,我得到了一系列的文章: $unsortedArticles = $this->article->getAllCurentTranslation($language); 我认为条款和优先权之间存在这种关系: public function priority() { return $this->hasOne('App\Models\HomepagePriority','article_id','id'); } 那么,我现在如何返回一个文章

有了这些,我得到了一系列的文章:

 $unsortedArticles = $this->article->getAllCurentTranslation($language);
我认为条款和优先权之间存在这种关系:

public function priority()
    {
      return $this->hasOne('App\Models\HomepagePriority','article_id','id');
    }
那么,我现在如何返回一个文章数组,而只返回那些没有优先级的文章???

您想要使用的文章。比如:

$articlesWithoutPriority = Aricle::doesntHave('priority')->get();
@Gerard Reches为您的案例提供的解决方案(假设
getAllCurentTranslation($language)
方法在末尾使用
->get()
):


但是在这个$unsortedArticles=$this->article->getAllCurrentTranslation($language);,我如何使用它呢?
$unsortedArticles = $this->article()
                         ->doesntHave('priority')
                         ->getAllCurentTranslation($language);