You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is Possible to define weights for enum members. the standard way is to define the weights a config file and them implement the `Weighted`-interface with the `IsWeighted`-trait and define the path to your config. The weigths can be defined as integer or float values.
333
+
334
+
```php
335
+
// The Enum
336
+
<?php
337
+
338
+
namespace App\Enums;
339
+
340
+
use Sourceboat\Enumeration\Enumeration;
341
+
use Sourceboat\Enumeration\Enums\Interfaces\Weighted;
342
+
use Sourceboat\Enumeration\Enums\Traits\IsWeighted;
343
+
344
+
/**
345
+
* @method static \App\Enums\UserType Administrator() // These are only for autocompletion etc.
With the model trait `HasWeightedEnumsScopes` you can easily search for models with enum values greater than one or between two other enum value, even with string values.
Much of the functionality in this Package is inspired by [bensampo/laravel-enum](https://github.com/bensampo/laravel-enum) and some code has been taken from it and modified, for example the `MakeEnumCommand.php`, the `EnumServiceProvider.php` and this readme.
0 commit comments