Create IF and SWITCH Statements With Blade Displaying data is one thing, but Blade has directives such as PHP’s if and switch statements. Blade directives are just shortcuts for implementing PHP code. You can even create your own Blade Directives, and we’ll look at that much later. For now, let’s focus on the built in ones: @if and @switch. Read the previous article on Displaying Data in Blade Files. @if Directive As mentioned above, blade directives replicate actual PHP code. The regular PHP way of writing an if statement is: <?php if ($something == true) { // Do something here } PHP also has the elseif and else statements that pair up with

Discussing Blade Directives We ended our previous article with a quick introduction into Blade. What we really wanted to achieve was introduce what Blade is, understand that there are Blade Directives, and figure out how to load our blade component once a specific route is hit. Read the previous articles on Blade Introduction. In this article, we go deeper. We’re going to look at the following concepts: Displaying Data Displaying Unescaped Data Displaying Data We looked at passing data in the previous article, but we’re going to review it once more. Let’s create a route and pass data to our