See if this fixes the failing test
This commit is contained in:
@@ -64,6 +64,7 @@ class ProjectController extends Controller
|
|||||||
public function show(Request $request, Project $project): Response
|
public function show(Request $request, Project $project): Response
|
||||||
{
|
{
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
abort_unless(
|
abort_unless(
|
||||||
$this->projectPermissionService->userCanViewProject($user, $project),
|
$this->projectPermissionService->userCanViewProject($user, $project),
|
||||||
403,
|
403,
|
||||||
@@ -112,6 +113,7 @@ class ProjectController extends Controller
|
|||||||
Project $project,
|
Project $project,
|
||||||
User $user,
|
User $user,
|
||||||
): RedirectResponse {
|
): RedirectResponse {
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
abort_unless(
|
abort_unless(
|
||||||
@@ -119,14 +121,7 @@ class ProjectController extends Controller
|
|||||||
403,
|
403,
|
||||||
);
|
);
|
||||||
|
|
||||||
$validated = $request->validated();
|
$this->projectPermissionService->syncUserPermissions($project, $user, $request->permissions());
|
||||||
$permissions = collect(Arr::get($validated, 'permissions'))
|
|
||||||
->map(fn (mixed $permission): string => (string) $permission)
|
|
||||||
->unique()
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
$this->projectPermissionService->syncUserPermissions($project, $user, $permissions);
|
|
||||||
|
|
||||||
return to_route('projects.access', $project)
|
return to_route('projects.access', $project)
|
||||||
->with('status', "{$user->name} permissions were updated.");
|
->with('status', "{$user->name} permissions were updated.");
|
||||||
@@ -142,14 +137,7 @@ class ProjectController extends Controller
|
|||||||
403,
|
403,
|
||||||
);
|
);
|
||||||
|
|
||||||
$validated = $request->validated();
|
$this->projectPermissionService->syncTeamPermissions($project, $team, $request->permissions());
|
||||||
$permissions = collect(Arr::get($validated, 'permissions'))
|
|
||||||
->map(fn (mixed $permission): string => (string) $permission)
|
|
||||||
->unique()
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
$this->projectPermissionService->syncTeamPermissions($project, $team, $permissions);
|
|
||||||
|
|
||||||
return to_route('projects.access', $project)
|
return to_route('projects.access', $project)
|
||||||
->with('status', "{$team->name} permissions were updated.");
|
->with('status', "{$team->name} permissions were updated.");
|
||||||
|
|||||||
@@ -33,4 +33,13 @@ class SyncProjectPermissionsRequest extends FormRequest
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function permissions(): array
|
||||||
|
{
|
||||||
|
return collect($this->validated('permissions', []))
|
||||||
|
->map(fn (mixed $permission): string => (string) $permission)
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user