public function edit(Request $request, $id)
{
//TODO: Cannot update error - Call to a member function syncPermissions() on int
//edit the role created
$this->validate($request, [
'name' => 'required',
'permission' => 'nullable'
]);
$role = Role::where('id', $id)->update([
'name' => $request->name,
]);
if ($request->has('permission')) {
$role->givePermissionTo($request->permission);
}
return $role;
}
i am trying to edit my roles and permissions using the code above, using Vue framework as the front end and this package is from spatie
the error on my response is
"message": "Call to a member function givePermissionTo() on int",
"exception": "Error",
my overall code works fine just the edit part that doesn't change