code: public function setPermissionsAttribute(array $permissions)
      {
          if (!$this->id) {
              $this->save();
          }
  
          $this->revokeAll();
  
          collect($permissions)->map(function ($permission) {
              if (!in_array($permission, Policy::all())) {
                  return;
              }
  
              $this->grant($permission);
          });
      }
docs: Replace all existing permissions with a new set of permissions
  
  @param array $permissions
  @return void