Answer the question
In order to leave comments, you need to log in
How can one get expected values with resolveRouteBinding?
I want to get an array of arguments that are expected in the method, for this:
class Example
{
/**
* @param \App\User $user
*
* @return \App\User
*/
public function run(\App\User $user)
{
return $user;
}
}
Route::get('/{user}', function () {
$example = new Example();
$class = new ReflectionClass($example);
$current = Route::current();
$arguments = $current->resolveMethodDependencies(
$current->parameters(),
$class->getMethod('run'),
);
dd($arguments);
});
array:2 [▼
0 => App\User {#359 ▶}
"user" => "1"
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question