Array AllPathsTasgs[] that has 2 path tags That has in the example
[
[
"php",
"HTML5",
"CSS3",
"XML"
],
[
"HTML5",
"CSS3",
"JavaScript",
"Bootstrab"
]
]
I'm Trying to get to Tasks that have tags like path tags using the line below
$query->whereNotIn('name', $AllPathsTasgs[$x]);
and is working fine with first path but it use first array in every path that means
the first path should be like
$query->whereNotIn('name', $AllPathsTasgs[$x]); and x here = 0
and this is ok but the problem is in the next path
$query->whereNotIn('name', $AllPathsTasgs[$x]); x = 0 not 1
don't know why this happens
foreach ($paths as $path){
$AllPathsTasgs[] = $path->pathtags->pluck('name');
}
$posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use ($AllPathsTasgs,$pathsTags) {
$q->with(['Tasks' => function ($q) use ($AllPathsTasgs,$pathsTags) {
$q->has('tasktags', '=', 2)
->orderBy('id', 'ASC')
->whereDoesntHave('tasktags', function ($query) use ($AllPathsTasgs,$pathsTags) {
for ($x = 0; $x < count($pathsTags); $x++) {
$query->whereNotIn('name', $AllPathsTasgs[$x]);
}
})->with('tasktags')->orderBy('id', 'ASC');
}]);
}])->whereIn('id',$pathId)->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire