Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct @elseif syntax in Blade of Laravel

Here is my code, I want to put an array of answers in just one @elseif line

 @if( $selectSummaryTable == 'MemType' )

                Summary of Members

 @elseif( $report_type == ['Category', 'CivilStatus'] )

                Baptism Report for {{ $report_date }}   

 @endif

How do you correctly put multiple values in the @elseif line?

like image 979
Rodney Zanoria Avatar asked Aug 22 '17 06:08

Rodney Zanoria


People also ask

What is Blade syntax in Laravel?

Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.

What is Blade syntax?

The Blade is a powerful templating engine in a Laravel framework. The blade allows to use the templating engine easily, and it makes the syntax writing very simple. The blade templating engine provides its own structure such as conditional statements and loops.

What is Blade directive in Laravel?

Blade directives are shortcut codes for the implementation of basic PHP structure control, such as loop and conditional statements. It makes your code snippets clean and easy to understand.


1 Answers

You can use in_array function , change your code from

@elseif( $report_type == ['Category', 'CivilStatus'] )

to

@elseif(in_array($report_type,['Category', 'CivilStatus']))
like image 89
wahdan Avatar answered Oct 28 '22 05:10

wahdan