1: <?php
2:
3: namespace LaravelUi5\Core\Enums;
4:
5: /**
6: * Declares where a parameter is sourced from in the request.
7: *
8: * *Body* parameters are intentionally not supported here.
9: *
10: * Actions should validate request bodies via Laravel’s native
11: * `$request->validate()` inside the ActionHandler.
12: *
13: * This separation ensures clean semantics
14: * - *Route/Query* → declarative parameters (resolved upfront).
15: * - *Body* → payload handled by Laravel validation.
16: */
17: enum ParameterSource: int
18: {
19: /**
20: * Extracted from route segments.
21: *
22: * - Always allowed (Actions, Reports, Resources).
23: * - Typical usage: identifiers (`/api/user/42/toggle-lock`).
24: */
25: case Path = 1;
26:
27: /**
28: * Extracted from the query string (`?from=2024-01-01&to=2024-12-31`).
29: *
30: * - Allowed for *GET-based providers* (Reports, Resources).
31: * - *Forbidden for Actions* (POST).
32: *
33: * Controllers should enforce this rule and abort with 400 if a `Query`
34: * parameter is defined on an Action.
35: */
36: case Query = 2;
37:
38: /**
39: * Returns a symbolic label, e.g., 'Path'.
40: */
41: public function label(): string
42: {
43: return match ($this) {
44: self::Path => 'Path',
45: self::Query => 'Query',
46: };
47: }
48: }
49: