0

I need to specify my styles under certain conditions

<div class="flex-container">
                @foreach($topServers as $server)
                    <div class="flex-item">
                        <div class="row">
                            @foreach($guilds as $guild)
                                @if($server->id == $guild->id)
                                    <img class="col-md-auto avatar" src="..." alt="">
                                @endif
                            @endforeach
                        </div>
                    </div>
                @endforeach
            </div>

Provided that $server->premium >= 1, you need to specify the "border-color:gold" styles in the div class="flex-item"

And I absolutely do not understand how to implement it, thank you in advance for your help

1 Answer 1

1

Just use a ternary to add a style.

<div class="flex-item" {{ $server->premium >= 1 ? 'style="border-color:gold"' : '' }}>
Sign up to request clarification or add additional context in comments.

2 Comments

Or even better ... use a class (I know OP asked for style).
@F.Müller Yep, either way it will work. For a class, the ternary would just need to be moved inside of the class attribute

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.