Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Blade Tag Condition in one line Laravel

i have a code that show if condition in my blade like this

@if($user->status == "Y")
     <span class="badge bg-success">Active</span>
@else
     <span class="badge bg-danger">Not Active</span>
@endif

And i want it show in one line This if condition like this:

{{ $user->status ? Active : Not Active }}

but it doesn’t work with html span tag in it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried this code

{{ $user->status ?echo "<span class="badge bg-success">Active</span>" : echo "<span class="badge bg-danger">Not Active</span>" }}

And still it doesn’t work

>Solution :

Just simply put into where you want to rendered.

<span class="badge bg-{{ $user->status ? 'success' : 'danger' }}">{{ $user->status ? 'Active' : 'Not Active' }}</span>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading