sohelamin / crud-generator

Laravel CRUD Generator
https://packagist.org/packages/appzcoder/crud-generator
MIT License
1.41k stars 424 forks source link

Use implicit bind in generated controllers? #252

Closed thumbtech closed 2 years ago

thumbtech commented 4 years ago

I had a problem with adding policy authorizeResource method to a generated controller because the methods didn't use implicit binding. E.g. for model Site

    public function show($id)
    {
        $site = Site::findOrFail($id);
        return view('sites.show', compact('site'));
    }

needed to be

    public function show(Site $site)
    {
        return view('sites.show', compact('site'));
    }

Should you consider converting to latter convention, which would support the default policy stuff https://laravel.com/docs/6.x/authorization#via-controller-helpers ?