Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yadhul's avatar

i want to convert this laravel blade to php if else conditon

i need this laravel condition

@if ($truck->trip_type == 1) @else @endif

to

php echo variable type.. like '($list->trip_type) .' .............. pls answer my question

0 likes
9 replies
zachleigh's avatar

{!! $list->trip_type !!} Will print the variable.

Snapey's avatar

What?

Surely you know how to write php?

<?php
    if($truck->trip_type == 1) {
        echo $list->trip_type;
     } else  {
        // else 
    }
?>
yadhul's avatar
Trip Type
                    <br><span class="btm-txt"><label title="@if ($truck->trip_type == 1){!! 'Regular Type' !!} @else {!!'Return  Type' !!} @endif" data-toggle="tooltip" data-placement="bottom"> @if ($truck->trip_type == 1)<img src="{!! 'img/reg_truck.png'  !!}"> @else <img src="{!! 'img/return_truck.png'  !!}"> @endif</label></span></div></td>

now this one i want to write in controller...

Trip Type
         <br><span class="btm-txt"><label onmouseover="$(this).tooltip();" title="'. $list->trip_type .'" data-toggle="tooltip" data-placement="bottom">'.($list->trip_type).'</label><br></div></td>   

in this here i want to write if else condition. iam not able to write pls help me @Snapey @zachleigh

pmall's avatar

Absolutely no idea what the question is. We cant help you if you cant explain us what you want to do.

yadhul's avatar

actually their is if else condtion in laravel i used in one page.. its working perfectly ...

now one public search controller is their...in that i want to write that condition where i can call images in that

when trip_type == 1 that too.. so here in this conditon is just echoing value like trip type 1 and trip type 2 but i want to reflect image when trip type==1 and trip type ==2 other image (this condtion ) need to implement in the below code how..?



@pmall

pmall's avatar

You know you need basic php skills in order to use laravel. If you cant change a string based on a condition I doubt you can use laravel correctly.

pmall's avatar

Well if you are a beginner you should start by mastering basic programming/basic php. Laravel is a tool on top of this.

zachleigh's avatar

What pmall said. If you cant write even basic php statements you're going to have a lot of trouble with Laravel. Before jumping into a framework, learn php and at least a little OOP.

Please or to participate in this conversation.