samedi 31 décembre 2016

Finding the first item in a foreach?

I am trying to add the class 'active' if tis the first item in a foreach but I keep getting a parse error? I am using Laravel and Blade, this is how I pass $members

public function getView()
    {
        Cache::remember('members.members', 1, function() {
            return Player::orderBy('id', 'DESC')->where('display_member', '=', '1')->limit(10)->get();
        });

        return view('frontend.members')->withMembers(Cache::get('members.members'));
    }

Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)

<div class="tab-content">
    @if ($members->count() > 0)
        @foreach ($members as $key => $member)
        <div role="tabpanel" class="tab-pane @if($members->first() == $member)active@endif" id="">
            <div class="col-md-12">
                <h1></h1>
                <br>
                <p>Personal Website: <a href=""></a></p>
                <p>Last Login: 1st January, 2017</p>
            </div>
        </div>
        @endforeach
    @endif
</div>

Aucun commentaire:

Enregistrer un commentaire