Back

Hey Laravel Developers

If you have ever worked with enums in PHP, you should know about the cases() method that comes with enums.

The cases() method basically returns all the different cases available inside the Enum, which you can iterate over using a loop.

For example, in the code snippet below, we are using the cases() method to return all the possible roles in the application, which is then used to render a select input on the front end.

image

89

  • No matching results...
  • Searching...

/ 1000