Removing duplicates from My relations

Posted 2 months ago by Kareimovich

i have relation tags that nave many tasks every tag have some tasks i need to return un duplicated Tasks values

My Controller

    $Tasks= Path::with(['pathtags' => function ($q) use ($TagArray)
     {$q->with(['Tasks' => function ($q) use ($TagArray) {$q->has('tasktags', '=', 2)
    }])->where('id', '=', 1)->get();

My Blade

     @foreach ($posts2 as $item)
            <h2> {{$item->name}}</h2>

     @foreach ($item->pathtags as $Tag)
           <li> Path Tag :: {{ $Tag->name }} </li>

   @foreach ($Tag->Tasks as $Task)          
           <li> Task :: {{ $Task->task_name }} </li>

   @foreach ($Task->tasktags as $TaskTag)
          <li> Task Tags :: {{ $TaskTag->name }} </li>


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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.