51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Back\GitlabProjects;
|
|
|
|
use App\Models\GitlabProject;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
/**
|
|
* Handles authorization and validation for creating a new GitlabProject.
|
|
*/
|
|
class StoreGitlabProjectRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::check('create', GitlabProject::class);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|between:3,255',
|
|
'url' => 'required|string|url:http,https|unique:gitlab_projects,url',
|
|
'gitlab_id' => 'required|integer|unique:gitlab_projects,gitlab_id',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => trans('validation.custom.name'),
|
|
'url' => trans('validation.custom.url'),
|
|
'gitlab_id' => trans('validation.custom.gitlab_id'),
|
|
];
|
|
}
|
|
}
|