ldc-supportweb/app/Http/Requests/Back/GitlabProjects/UpdateGitlabProjectRequest.php
2026-05-19 16:47:07 +02:00

48 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Back\GitlabProjects;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
/**
* Handles authorization and validation for updating an existing GitlabProject.
*/
class UpdateGitlabProjectRequest extends StoreGitlabProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
#[\Override]
public function authorize(): bool
{
return Gate::check('update', $this->route('gitlab_project'));
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
#[\Override]
public function rules(): array
{
/** @var \App\Models\GitlabProject $gitlab_project */
$gitlab_project = $this->route('gitlab_project');
return array_merge(parent::rules(), [
'url' => [
'required',
'string',
'url:http,https',
Rule::unique('gitlab_projects', 'url')->ignore($gitlab_project->getRouteKey()),
],
'gitlab_id' => [
'required',
'integer',
Rule::unique('gitlab_projects', 'gitlab_id')->ignore($gitlab_project->getRouteKey()),
],
]);
}
}