Encapsulation is the practice of bundling data (properties) and methods (functions) that work on that data within a single unit—the class. Crucially, it involves restricting direct access to some of an object's components (using public , protected , or private visibility modifiers) to protect the integrity of the data.
While powerful, inheritance can be overused. If you create deep chains of inheritance (e.g., User -> AdminUser -> SuperAdminUser ), your code becomes rigid and hard to change. object-oriented principles in php laracasts download
class Role public function permissions() return ['edit', 'delete']; Encapsulation is the practice of bundling data (properties)