File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 22
33All notable changes to ` laravel-backed-enums ` will be documented in this file.
44
5+ ## Add support for direct value comparisons - 2023-02-27
6+
7+ Right now if you want to use ` ->isA ` or ` ->isAny ` or the other comparison methods you must pass in an enum instance, I.e.
8+
9+ ``` php
10+ $user->role->isA(MyEnum::from('admin')); // true
11+ $user->role->isA('admin'); // false
12+
13+ $user->role->isA(MyEnum::from('not-a-value')); // exception
14+ $user->role->isA('not-a-value'); // false
15+
16+ $user->role->isAny([MyEnum::from('admin')]); // true
17+ $user->role->isAny(['admin']); // false
18+
19+ $user->role->isAny([MyEnum::from('not-a-value')]); // exception
20+ $user->role->isAny(['not-a-value']); // false
21+
22+ ```
23+ This release makes it so each pair of methods will act the same whether given a string value or an enum instance.
24+
25+ ``` php
26+ $user->role->isA(MyEnum::from('admin')); // true
27+ $user->role->isA('admin'); // true
28+
29+ $user->role->isA(MyEnum::from('not-a-value')); // exception
30+ $user->role->isA('not-a-value'); // exception
31+
32+ $user->role->isAny([MyEnum::from('admin')]); // true
33+ $user->role->isAny(['admin']); // true
34+
35+ $user->role->isAny([MyEnum::from('not-a-value')]); // exception
36+ $user->role->isAny(['not-a-value']); // exception
37+
38+ ```
39+ This also applies for isAn, isNotA, isNotAn, isNotAny
40+
541## v1.2.1 - 2023-02-22
642
743### What's Changed
You can’t perform that action at this time.
0 commit comments