-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from bskl/get-enum-value
Get value from model with casts php native enum
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Spatie\Html\Test\Stubs; | ||
|
||
enum Role | ||
{ | ||
case User; | ||
case Manager; | ||
case Admin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Spatie\Html\Test\Stubs; | ||
|
||
enum Status: int | ||
{ | ||
case Unknown = 0; | ||
case Pending = 1; | ||
case Complete = 2; | ||
|
||
/** | ||
* Get the enum as an array formatted for a select. | ||
* | ||
* @return array | ||
*/ | ||
public static function asSelectArray() | ||
{ | ||
return array_column(self::cases(), 'name', 'value'); | ||
} | ||
} |