使用更新权限页面违反完整性约束

I'm using Laratrust Package with laravel 5.5, and I have made a page to create users with their roles and permissions. This is working well, but the problem is with my update page. I can't update the value of permissions and I don't know why.

Here is my code for the update page:

public function update(Request $request, User $user)
{
     $request_data = User::find(1);

     $request->validate([
         'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255|unique:users',

    ]);
   $request_data=$request->except(['permissions']);


    $user->update($request_data);
     $user->syncPermissions($request->permissions);

      return redirect('dashboard/index');

}

And this is my edit blade page:

<form class="m-form m-form--fit m-form--label-align-right m-form--group-seperator" method="post" action="{{ url('dashboard/update/users',$user->id) }}">
     {{ csrf_field() }}
     {{ method_field('put') }}
     <div class="m-portlet__body">           
         <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                        <label for="name" class="col-md-4 control-label">Name</label>

                        <div class="col-md-6">
                            <input id="name" type="text" class="form-control" name="name" value="{{ $user->name }}" required autofocus>

                            @if ($errors->has('name'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('name') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

First, take a look at this line:

$request_data = User::find(1);

I'm not sure why this is in there - you redefine this immediately following the validation. Suggest remove it.

The problem with the update of the permissions might be in the way you have structured your sync() method. This is the way I'm used to seeing this:

$user->permissions()->sync($request->get('permissions', []));

The [] is optional, but give this a try and see if it helps.

Also, I'm not sure where the permissions are coming from on the $request object. Perhaps you didn't include it in your code snippet above, but I'm not seeing where this gets assigned in the blade file. Thus, the above update code in my answer (Laravel standard rather than the package format) should at least work - it should revert to no perms if there is indeed no permissions field on the form to change the perms

You can delete records of role_permission then attach with new permissions

$user->syncPermissions($request->permissions);

This may help you ,if no any methods in the package update the values