Improve exception handling and model binding

This commit is contained in:
Jonny Barnes 2020-08-09 15:54:10 +01:00
parent e9ca934cb4
commit 0fca80e7e4
22 changed files with 148 additions and 82 deletions

View file

@ -12,7 +12,7 @@ class PlacesController extends Controller
/**
* Show all the places.
*
* @return \Illuminate\View\View
* @return View
*/
public function index(): View
{
@ -24,13 +24,11 @@ class PlacesController extends Controller
/**
* Show a specific place.
*
* @param string $slug
* @return \Illuminate\View\View
* @param Place $place
* @return View
*/
public function show(string $slug): View
public function show(Place $place): View
{
$place = Place::where('slug', '=', $slug)->firstOrFail();
return view('singleplace', ['place' => $place]);
}
}