Skip to content

Commit ccb8d46

Browse files
committed
docs: reword documentation about route binding
1 parent a0a765b commit ccb8d46

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Web/Documentation/content/main/1-essentials/02-controllers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ final readonly class AircraftController
8282

8383
### Route binding
8484

85-
When injecting objects (like for examples, [models](/main/essentials/models)) in controller actions, Tempest can map the route parameter directly to the object, given that that object's class implements the {`Tempest\Router\Bindable`} interface:
85+
In controller actions, you may want to receive an object instead of a scalar value such as an identifier. This is especially useful in the case of [models](/main/essentials/models) to avoid having to write the fetching logic in each controller.
8686

8787
```php app/AircraftController.php
8888
use Tempest\Router\Get;
@@ -96,14 +96,16 @@ final class AircraftController
9696
}
9797
```
9898

99+
Route binding may be enabled for any class that implements the {`Tempest\Router\Bindable`} interface, which requires a `resolve()` method responsible for returning the correct instance.
100+
99101
```php
100102
use Tempest\Router\Bindable;
101103
use Tempest\Database\IsDatabaseModel;
102104

103105
final class Aircraft implements Bindable
104106
{
105107
use IsDatabaseModel;
106-
108+
107109
public function resolve(string $input): self
108110
{
109111
return self::find(id: $input);

0 commit comments

Comments
 (0)