I have relation tags that have many tasks whet I get data from foreach I get duplicated values
in example
in my path i have 2 tags PHP ,HTML5
PHP Has [PHP Task_1 , PHP_Task_2]
HTML5 Has [HTml5 Task_1,PHPTask_2]
because task has many tags so i will get to duplicated PHP_Task_2
i need to get every task just one time
My Controller
$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray)
{$q->with(['Tasks' => function ($q) use ($TagArray) {$q->has('tasktags', '=', 2)
->with('tasktags');
}]);
}])->where('id', '=', 1)->get();
My Blade
@foreach ($posts2 as $item)
<h2> </h2>
@foreach ($item->pathtags as $Tag)
<li> Path Tag :: </li>
@foreach ($Tag->Tasks as $Task)
<li> Task :: </li>
@foreach ($Task->tasktags as $TaskTag)
<li> Task Tags :: </li>
@endforeach
@endforeach
@endforeach
@endforeach
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Dayr2U
via IFTTT
Aucun commentaire:
Enregistrer un commentaire