2026-03-11 23:33:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
|
|
use App\Enums\WorkspaceUserRole;
|
|
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
|
|
class UpdateWorkspaceRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->user() !== null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
/** @var Workspace $workspace */
|
|
|
|
|
$workspace = $this->route('workspace');
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'name' => ['required', 'string', 'max:255'],
|
|
|
|
|
'slug' => ['nullable', 'string', 'max:255', Rule::unique(Workspace::class)->ignore($workspace->id)],
|
|
|
|
|
'user_ids' => ['array'],
|
|
|
|
|
'user_ids.*' => ['integer', 'exists:users,id'],
|
|
|
|
|
'user_roles' => ['nullable', 'array'],
|
2026-03-12 18:25:32 +00:00
|
|
|
'user_roles.*' => ['string', 'in:'.implode(',', WorkspaceUserRole::getValues())],
|
2026-03-11 23:33:10 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|