Skip to content

Support for Model Router Binding #310

@ibnsultan

Description

@ibnsultan

Hey @mychidarko,

Do we currently have support for model-router binding similar to Laravel?

For example, something like this:

app()->get('/users/{user}', function (User $user) {
    echo $user;
});

In Laravel, we can specify the binding rules for a given route parameter and define how it should be resolved. For instance:

public function bindParameterUser(): void
{
    Route::bind('user', function ($value) {
        return User::with('posts')
            ->orWhere('hash', $value)
            ->firstOrFail();
    });
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions