获取正确任务的路径

时间:2018-12-07 08:27:45

标签: php laravel loops foreach eloquent

大家好,我正在尝试获取具有与path相同标签的Task 所以路径有很多标签=>标签有很多任务=>任务有很多标签
       因此,我试图使$ TagArray具有当前的路径标签,但我不知道该怎么做,请帮忙

               $query->whereNotIn('name', $TagArray);


 $user = User::where('id' ,$user->id)->with('paths.pathtags')->first();
    $pathId = $user->paths->pluck('id');
    $paths = Path::with('pathtags')->whereIn('id',  $pathId)->get();


         foreach ($paths as $path){
        $AllPathsTasgs [] = $path->pathtags->pluck('name');
    }
       foreach ($AllPathsTasgs as $TagArray){

        $posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use ($TagArray)
        {$q->with(['Tasks' => function ($q) use ($TagArray)
           {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
           ->whereDoesntHave('tasktags',

           function ($query) use ($TagArray) {

               $query->whereNotIn('name', $TagArray);

           }
       )
               ->with('tasktags')->orderBy('id', 'ASC');
           }]);
       }])
       ->whereIn('id', $pathId)->get();
    }

0 个答案:

没有答案