0

How do i set different states of the icon? I want it to change between a liked/not liked icon. Can i do that? I don't completely understand the syntax. The btn-success class is for the liked icon, and btn-danger is for the unliked button.

        @if(Auth::check())
        @if( !$unblock )
        <span data-id="{{ $key->id }}" data-like="Like" data-like-active="Remove Like" title="@if(!empty($likeUser)) Remove Like @else Like @endif" class="btn btn-xs pull-left @if(!empty($likeUser)) btn-success @else btn-danger @endif btn-like likeButton @if(!empty($likeUser)) active @endif">
            <i class="Like-icon"></i>
        </span>
        @else

2 Answers 2

2

You're almost right just complete the condition after @else

Here is the place to learn more about blades and templates

It is as simple like regular PHP if..else condition

@if (Auth::check())
Authorized
@else
Nope
@endif

If you want to have additional conditions inside then

@if (Auth::check())
Authorized
//your additional conditions for authorized users
@else
Nope
@endif
Sign up to request clarification or add additional context in comments.

Comments

1
@if (count($records) === 1)
  I have one record!
@elseif (count($records) > 1)
  I have multiple records!
@else
  I don't have any records!
@endif

1 Comment

Mind to explain your solution a bit?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.