app/Api/V1/Controllers/PermissionController.php
/**
     * Remove the specified permission from storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return Response
     * @throws \Illuminate\Validation\ValidationException
     */
Remove the specified permission from storage.
Remove the specified permission from storage .
public function destroy(Request $request)
    {
        $this->validate($request, [
            'permission_name' => 'required|string'
        ]);
        $permission_name = $request->permission_name;
        $permissions = $this->generatePermissions($permission_name);
        if (Permission::query()->where('name', 'LIKE', '%'. $this->getNameArgument($permission_name))->delete()) {
            if ($role = Role::query()->where('name', 'admin')->first()) {
                $role->syncPermissions(Permission::all());
            }
            return new Response(['status'=>  'Permissions ' . implode(', ', $permissions) . ' deleted.' ], 201);
        }
        throw new DeleteResourceFailedException('No permissions for ' . $this->getNameArgument($permission_name) .' found!');
    }
public function destroy ( Request $ request ) { $ this -> validate ( $ request , [ 'permission_name' => 'required|string' ] ) ; $ permission_name = $ request -> permission_name ; $ permissions = $ this -> generatePermissions ( $ permission_name ) ; if ( Permission :: query ( ) -> where ( 'name' , 'LIKE' , '%' . $ this -> getNameArgument ( $ permission_name ) ) -> delete ( ) ) { if ( $ role = Role :: query ( ) -> where ( 'name' , 'admin' ) -> first ( ) ) { $ role -> syncPermissions ( Permission :: all ( ) ) ; } return new Response ( [ 'status' => 'Permissions ' . implode ( ', ' , $ permissions ) . ' deleted.' ] , 201 ) ; } throw new DeleteResourceFailedException ( 'No permissions for ' . $ this -> getNameArgument ( $ permission_name ) . ' found!' ) ; }
Remove the specified permission from storage.
Remove the specified permission from storage .
// remove permission // sync role for admin