Join Joseph Lowery for an in-depth discussion in this video Defining conditions, part of Learning Laravel.
Conditional statements keep templates…flexible and responsive.…Whether you're talking a basic "if else" statement,…a "do while" type loop,…or the uniquely Laravel "unless" statement,…Blade has all the power you need to execute…a wide range of conditional,…or as they're sometimes called, "control" statements.…Let me introduce you to a few of them.…We'll start with a basic "if else" condition…and I'll start the ball rolling by adding…a second variable to my array in the "roots" dot php file.…
On line 16, I'm going to declare a new variable…within my array, call it "theWeather,"…and make that equal to "sunny."…I'll save the file and then switch over…to my "hello" dot "blade" dot php template.…Let me scroll over just a little bit,…so I'm in front of the h1 class.…Actually, an easier way to approach it…would be from the end.…This is where I'll put in my conditional statement.…
The Blade syntax for an "if else" statement…is simplicity itself.…Preface each condition with an at sign, like so,…and you're pretty much good to go.…
- Installing Laravel
- Handling testing
- Establishing an HTML view
- Connecting to a database
- Enabling version control
- Setting up-and-running unit tests
Skill Level Intermediate
1. Introduction to Laravel
2. Creating Initial Laravel Pages
3. Displaying Laravel Code
4. Creating a Laravel Application
5. Testing Your Laravel Code
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.