Back to the Learning!

Laracasts is packed full with over 1,000 lessons just like this one.

Sign up to get full access or log in to your account and sit back.

Published On Feb. 16th 2017

How to Accept Payments: How to Reduce Conditionals in Your Views

Episode 20 Run Time 5:36

Download
In the previous episode, we constructed multiple conditionals to determine which set of HTML should be displayed. For our basic example, the outcome was simple enough. However, for real-life projects, you may find that this quickly bloats your views and makes them difficult to reason about. Instead, let me show you a useful technique that involves applying polymorphism to dynamically load the proper view partial.