return tasks with same tags as path

Posted 6 months ago by Kareimovich

Hi Everyone I have made for loop so I can compare every path tasktags to AllPathsTasgs So I can return only tasks that have same tags like the path tags but it returns tasks that have tags in all path tags any help, please

     foreach ($paths as $path){
          $AllPathsTasgs [] = $path->pathtags->pluck('name');
        $posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use         
         {$q->with(['Tasks' => function ($q) use ($AllPathsTasgs)
             {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
           function ($query) use ($AllPathsTasgs) {
            for ($x = 0; $x < count($AllPathsTasgs); $x++) {
                $query->whereNotIn('name', $AllPathsTasgs[$x]);

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

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.