-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
When using the hash ids for a model as per the documentation, if you create a custom action using withId(), you can not type hint the model correctly:
class MyController extends JsonApiController
{
/**
* @param MyModel $model
*/
public function customActionHandler(MyModel $model)
{This code will give you a 404:
{
"detail": "No query results for model [App\\Models\\MyModel] x6Qe6n",
"status": "404",
"title": "Not Found"
}It seems to me that somewhere in Illuminate\Routing\router::substituteImplicitBindings() it can't resolve an instance of the model based on the hash id.
If you change the type hint to mixed, you don't get the 404 and you still have the correct model passed:
public function customActionHandler(mixed $model)I've had a look through the docs but can't see any config step that I've missed in terms of setting up hash IDs correctly, given the comments in the docs that custom actions are not likely to be needed, and hash IDs are optional, this might be an edge case when using the two.
Metadata
Metadata
Assignees
Labels
No labels