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
| init(>name<,>cast<) |```["name"=> >name<]```|\>name< = instanceof PreferenceGroup | Unique identifier for the preference |
424
+
| init(>name<,>cast<) |```["cast"=> >cast<]```|\>cast< = instanceof CastableEnum | Caster to translate the value between all different scenarios. Currently: Api-calls as well as saving to and retrieving fron the DB |
425
+
| nullable(>nullable<) |```["nullable"=> >nullable<]```|\>nullable< = bool | Whether the default value can be null and if the preference can be set to null |
426
+
| withDefaultValue(>default_value<) |```["default_value"=> >default_value<]```|\>default_value< = mixed, but must comply with the cast & validationRule | Initial value for this preference |
427
+
| withDescription(>description<) |```["description"=> >description<]```|\>description< = string | Legacy code from v1.x has no actual use as of now |
428
+
| withPolicy(>policy<) |```["policy"=> >policy<]```|\>policy< = instanceof PreferencePolicy | Authorize actions such as update/delete etc. on certain preferences. |
429
+
| withRule(>rule<) |```["rule"=> >rule<]```|\>rule< = instanceof ValidationRule | Additional validation Rule, to validate values before setting them |
430
+
| setAllowedClasses(>allowed_values<) |```["allowed_values"=> >allowed_values<]```|\>allowed_values< = array of string classes. For non Primitive Casts only | Current use-cases: <br/> - restrict classes of enum or object that can be set to this preference<br/> - reconstruct the original class when sending data via api. |
431
+
415
432
## Routing
416
433
417
434
off by default, enable it in the config
418
435
419
-
> Current limitation: it's not possible to set enums/object casts via API
420
-
> Enum support planned for v2.2
436
+
> Current limitation: it's not possible to set object casts via API
421
437
422
438
### Anantomy:
423
439
@@ -480,11 +496,19 @@ will result in:
480
496
(my_preferences.user.general.index)
481
497
equivalent to: `$user->getPreferences(General::class)`
482
498
499
+
```shell
500
+
curl -X GET 'https://example.com/my_preferences/user/{scope_id}/general'
501
+
```
502
+
483
503
#### GET
484
504
485
505
(my_preferences.user.general.get)
486
506
equivalent to: `$user->getPreference(General::{preference})`
487
507
508
+
```shell
509
+
curl -X GET 'https://example.com/my_preferences/user/{scope_id}/general/{preference}'
0 commit comments