PHP 8.1: Enums - Everything You Need To Know How to use enumerations in Laravel?


PHP 8.1 adds support for Enumerations.
An Enumeration or an Enum for short is an enumerated type that has a fixed number of possible values.
Thats all cool and stuff but whats a practical real-world example of where we would want this? How could this be used by developers in their projects? In my explanation Ill use PHP and Laravel code but the idea behind enums can be applied to other PHP frameworks or core PHP as well. Enums in PHP v8.1 Explained in detail with examples. How to use the enumerationsEnums of PHP 8.1 in Laravel? 1: Single Responsibility Principle SRP 2: Open-Closed Principle OCP in PHP Laravel 3: Liskov substitution principle LSP in PHP Laravel 4: Interface Segregation Principle ISP in PHP Laravel 5: Dependency inversion principle DIP in PHP Laravel How to modify created_at updated_at timestamps in Laravel? How to use UUID as the Primary key instead of auto-increment IDs in the Laravel application? Laravel Model Lifecycle Events and How to use Observers in Laravel? 1: SPA Authentication using Laravel Sanctum 2: API Token Authentication using Laravel Sanctum Laravel Eloquent Relationships TABLE OF CONTENTS 00:00 - Intro 00:13 - Before built-in Enums the use of Constant the problem of it. 09:39 - Introduction of PHP 8.1: Enums feature. 11:36 - Pure enums vs Backed enums. 14:52 - Access value of Backed enums. 15:58 - The solutions to the problems with the usage of Constants using Enums. 18:25 - Methods in enums. 19:19 - from tryFrom methods in the Enums. 22:10 - Methods in enums. 27:01 - Enum Attribute Casting in Laravel Application 28:28 - Store or update Enum values in the Database in Laravel App 29:41 - Get a list of all cases 33:01 - Enum validation rule in Laravel 34:46 - Classes vs Enums 36:29 - Traits 37:34 - Classes vs Enums Support my work: On BuyMeACoffee: ???????????? ???????? Also follow us on: ????????: ???????:

Источник: rutube.ru

Сообщение от Commenton: Необходимо стартовать сессию