Skip to content

Commit b3c75ce

Browse files
author
Toni Peric
committed
Add human-friendly message to MethodNotAllowedHttpException
Closes #26355
1 parent 94a54fc commit b3c75ce

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Illuminate/Routing/RouteCollection.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,28 @@ protected function getRouteForMethods($request, array $methods)
239239
}))->bind($request);
240240
}
241241

242-
$this->methodNotAllowed($methods);
242+
$this->methodNotAllowed($methods, $request->method());
243243
}
244244

245245
/**
246246
* Throw a method not allowed HTTP exception.
247247
*
248248
* @param array $others
249+
* @param string $method
249250
* @return void
250251
*
251252
* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
252253
*/
253-
protected function methodNotAllowed(array $others)
254+
protected function methodNotAllowed(array $others, $method)
254255
{
255-
throw new MethodNotAllowedHttpException($others);
256+
throw new MethodNotAllowedHttpException(
257+
$others,
258+
sprintf(
259+
'Method %s is not allowed. Allowed methods: %s.',
260+
$method,
261+
implode(', ', $others)
262+
)
263+
);
256264
}
257265

258266
/**

0 commit comments

Comments
 (0)