Laravel Tip ⚡ Ever heard of the "Tell, Don't Ask" principle? It states that we should not fetch data from an object to do conditional checks upon it, instead, we should ask the object to do that for us. Added benefits: clear intention, reusable logic & less error-prone code.
@phpfour This is called encapsulation, and is a pillar of OOP 🙂
@phpfour It’s a great approach in general. But one problem with this specific example is, the model continues growing with time. At one point thar model can become unmaintanable. How do you approach solving that issue?
@phpfour The absolute best way. My method name OCD will want it to read as close to English to possible :) if ($lesson->contentIsUnlocked())
@phpfour Good advice, one of my favourite "self documenting code" techniques 🤓
@phpfour I always thought this was more common in large project for maintainability.