get array from foreach

Posted 2 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.

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

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.