Laravel View return different Data from Controller

Posted 8 months ago by Kareimovich

Hi everybody, My code here is returning tasks that have more than 1 Tag and the code is working fine until I pass it to view it returns all tasks even tasks that have one tag My Code

My Controller :

$posts = Path::with(['pathtags' => function ($q)  {
         $q->has('tasktags', '=' , 2)->with('tasktags');

My View : return view ('task',compact('posts'));

@foreach ($posts as $Task)
<h2>{{ $Task->name }}</h2>

@foreach ($Task->pathtags as $Tag)
<h3>{{ $Tag->name }}</h3>

@foreach ($Tag->tasks as $Ta)
<h2>{{ $Ta->task_name }}</h2>



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