laravel-code-generator icon indicating copy to clipboard operation
laravel-code-generator copied to clipboard

Route Model Binding

Open AjithLalps opened this issue 5 years ago • 0 comments

Is your feature request related to a problem? Please describe. The generated controller file has find() function to find any object. like below:

 public function update($id, TourCategoriesFormRequest $request)
    {
        try {
          ....
          $tourCategory = TourCategory::findOrFail($id);
          ....
        } catch (Exception $exception) {
         ...
        }
    }

Describe the solution you'd like We can use laravel's Route Model Binding. Ref:https://laravel.com/docs/7.x/routing#route-model-binding for cleaner and faster code

AjithLalps avatar Mar 11 '20 10:03 AjithLalps