Skip to content

Commit c72b2ca

Browse files
committed
Added Model binding support for Auto Routes.
1 parent 28e975b commit c72b2ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/AutoRoute.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Buki\AutoRoute;
44

55
use Illuminate\Container\Container;
6+
use Illuminate\Database\Eloquent\Model;
67
use Illuminate\Routing\Router;
78
use ReflectionClass;
89
use ReflectionMethod;
@@ -181,7 +182,8 @@ private function getRouteValues(ReflectionMethod $method, array $patterns = []):
181182
$typeHint = $param->hasType() ? $param->getType()->getName() : null;
182183

183184
if ($typeHint !== null && class_exists($typeHint)) {
184-
if (!in_array($typeHint, ['int', 'float', 'string', 'bool']) && !in_array($typeHint, $patterns)) {
185+
if (!in_array($typeHint, ['int', 'float', 'string', 'bool']) && !in_array($typeHint, $patterns)
186+
&& !is_subclass_of($typeHint, Model::class)) {
185187
continue;
186188
}
187189
}

0 commit comments

Comments
 (0)