From bbd5d25e0b6dffadbbc8d4e412f1fd15e0ec3945 Mon Sep 17 00:00:00 2001 From: Jim-Webfox Date: Mon, 27 Feb 2023 20:45:24 +0000 Subject: [PATCH] Update CHANGELOG --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9cc986..7656da8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,42 @@ All notable changes to `laravel-backed-enums` will be documented in this file. +## Add support for direct value comparisons - 2023-02-27 + +Right now if you want to use `->isA` or `->isAny` or the other comparison methods you must pass in an enum instance, I.e. + +```php +$user->role->isA(MyEnum::from('admin')); // true +$user->role->isA('admin'); // false + +$user->role->isA(MyEnum::from('not-a-value')); // exception +$user->role->isA('not-a-value'); // false + +$user->role->isAny([MyEnum::from('admin')]); // true +$user->role->isAny(['admin']); // false + +$user->role->isAny([MyEnum::from('not-a-value')]); // exception +$user->role->isAny(['not-a-value']); // false + +``` +This release makes it so each pair of methods will act the same whether given a string value or an enum instance. + +```php +$user->role->isA(MyEnum::from('admin')); // true +$user->role->isA('admin'); // true + +$user->role->isA(MyEnum::from('not-a-value')); // exception +$user->role->isA('not-a-value'); // exception + +$user->role->isAny([MyEnum::from('admin')]); // true +$user->role->isAny(['admin']); // true + +$user->role->isAny([MyEnum::from('not-a-value')]); // exception +$user->role->isAny(['not-a-value']); // exception + +``` +This also applies for isAn, isNotA, isNotAn, isNotAny + ## v1.2.1 - 2023-02-22 ### What's Changed