the 3 tickmarks need to be on their own lines containing nothing else for the formatting to work. That code looks vaguely familiar ;)
One problem you'll have here is only the permissions that were selected in the multiselect will get sent in the request. Those are the true permissions. So, you'll also need to figure out which ones weren't sent in order to set the false permissions.
One way to do that is to have an array that has all possible permissions, and use array_diff() to determine which ones weren't sent in the request.
$selectedPermissions = $request->selectpermission;
$possiblePermissions = [
'view-editrole',
'view-role',
'view-orderwaiting',
'view-orderstatus',
'view-company',
];
// determine the permissions that weren't sent
$unsentPermissions = array_diff($possiblePermissions, $selectedPermissions);
//create an array using $selectedPermissions and fill values to `true`
$permissions = array_fill_keys($selectedPermissions, true);
// create an array using $unsentPermissions and fill values to `false`
$unsentPermissions = array_fill_keys($unsentPermissions, false);
// merge the 2 arrays
$permissions = array_merge($permissions, $unsentPermissions);
// convert it to json
$jsonPermissions = json_encode($permissions);
// save $jsonPermissions...
DB::table('roles')->where('id',$rid)->update(['permissions' => $jsonPermissions]);
It's a lot of code to do that, and it can be shortened, but I wanted it to be self-explanatory.