Set order to role permissions API response

This commit is contained in:
Dan Brown 2023-02-18 18:50:01 +00:00
parent 723f108bd9
commit 3c3c2ae9b5
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -4,7 +4,6 @@ namespace BookStack\Http\Controllers\Api;
use BookStack\Auth\Permissions\PermissionsRepo;
use BookStack\Auth\Role;
use BookStack\Exceptions\UserUpdateException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -127,7 +126,7 @@ class RoleApiController extends ApiController
{
$role->load('users:id,name,slug');
$role->unsetRelation('permissions');
$role->setAttribute('permissions', $role->permissions()->pluck('name'));
$role->setAttribute('permissions', $role->permissions()->orderBy('name', 'asc')->pluck('name'));
$role->makeVisible(['users', 'permissions']);
}
}