File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Webfox \LaravelBackedEnums ;
44
5+ use Illuminate \Validation \Rules \Enum as EnumValidationRule ;
56
67/**
78 * @implements \Webfox\LaravelBackedEnums\BackedEnum<string,string>
@@ -64,13 +65,21 @@ public static function labelFor(self $value): string
6465 return app ('translator ' )->has ($ lang_key ) ? __ ($ lang_key ) : $ value ->value ;
6566 }
6667
68+ public static function rule (): Rules \Enum
69+ {
70+ static ::ensureImplementsInterface ();
71+ return new EnumValidationRule (static ::class);
72+ }
73+
6774 public function label (): string
6875 {
76+ static ::ensureImplementsInterface ();
6977 return static ::labelFor ($ this );
7078 }
7179
7280 public function withMeta (): array
7381 {
82+ static ::ensureImplementsInterface ();
7483 return [];
7584 }
7685
You can’t perform that action at this time.
0 commit comments