get array from foreach

Posted 8 months ago by Kareimovich

Hi, everybody, I have foreach

  @foreach ($Tag->Tasks as $Task)

@if (!in_array($Task->id,$a))
    @if ($Task->slug == Request::segment(5) )

    @php
    $ATask[] = $Task;
@endphp

          <a href="{{ url('category/'.$item->ProgrammingField->slug.'/'.$item- 
     >slug.'/'.Request::segment(4).'/'.$Task->slug ) }}" style="text-decoration: none">
           <li class="list-group-item active" > Task NOn :: {{ $Task->task_name }}   ++  {{ $Task->id 
       }}
           </li></a>

 @else
 <a href="{{ url('category/'.$item->ProgrammingField->slug.'/'.$item->slug.'/'.Request::segment(4).'/'.$Task->slug ) }}" style="text-decoration: none">
    <li class="list-group-item" > Task NOn :: {{ $Task->task_name }}   ++  {{ $Task->id }}
     </li></a>

 @endif

     @php
        array_push($a,$Task->id);
     @endphp

     @endif

    @endforeach

When I use

{{ $ATask }}

i get Undefined variable:

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