Laravel-modules: Method [authorize] does not exist.

Created on 7 Oct 2016  路  4Comments  路  Source: nWidart/laravel-modules

Hello I have an error when calling the authorization in the controller

public function destroy($id)
{
if (auth()->check()) {
if (request()->method('delete')) {
try {
$stream = Stream::findOrFail($id);
$this->authorize('delete', Stream::class);
} catch (ModelNotFoundException $e) {
return response()->json(['status' => "error", 'message' => 'No existe lo buscado'], 409);
}

        } else {
            # code...
        }

    } else {
        # code...
    }

}

BadMethodCallException in Controller.php line 82:
Method [authorize] does not exist.

Most helpful comment

reviewing your library found something and made a change in her

use Illuminate\Routing\Controller;

for

use Nwidart\Modules\Routing\Controller;

in controller

All 4 comments

This isn't related to the package.
Looks like your method authorize was not found.

reviewing your library found something and made a change in her

use Illuminate\Routing\Controller;

for

use Nwidart\Modules\Routing\Controller;

in controller

do not know if I'm doing something wrong with her and excuse my English but not speak Spanish will write

You don't have to use that controller, you can just use laravel's base controller.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyberbaseza picture cyberbaseza  路  4Comments

abiodunjames picture abiodunjames  路  5Comments

quentingosset picture quentingosset  路  4Comments

guirociozanini picture guirociozanini  路  4Comments

pawlox picture pawlox  路  4Comments