Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if else condition in blade file (laravel 5.3)

Tags:

php

laravel

I want to check if/else condition in my blade file. I want to check the condition $user->status =='waiting' as the code given below. Output returns correctly as I expected. But along with my output I caught curly braces {} printed. I want to remove curly braces in result. Is there anything wrong in my if condition ?

@if($user->status =='waiting')          {            <td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>          }          @else{            <td>{{ $user->status }}</td>          }          @endif 
like image 243
user3386779 Avatar asked Oct 19 '16 05:10

user3386779


People also ask

What is __ In Laravel blade?

Laravel later introduced a great helper function __() which could be used for JSON based translations. For instance, in your blade files, {{ __('The Web Tier') }} Whereas “The Web Tier” is added in a JSON file inside of resources/lang directory i.e {locale}.json likeso, {

What is @yield used for in Laravel?

In Laravel, @yield is principally used to define a section in a layout and is constantly used to get content from a child page unto a master page.


1 Answers

No curly braces required you can directly write

@if($user->status =='waiting')                <td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>          @else       <td>{{ $user->status }}</td>         @endif 
like image 50
Rakesh Sojitra Avatar answered Sep 21 '22 17:09

Rakesh Sojitra