41 lines
1006 B
PHP
41 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ValidateProjectTicketBranchRequest 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
|
|
{
|
|
return [
|
|
'branch_name' => ['required', 'string', 'max:255'],
|
|
'repository_connection_id' => ['required', 'integer', 'exists:repository_connections,id'],
|
|
];
|
|
}
|
|
|
|
public function branchName(): string
|
|
{
|
|
return trim((string) $this->validated('branch_name'));
|
|
}
|
|
|
|
public function repositoryConnectionId(): int
|
|
{
|
|
return (int) $this->validated('repository_connection_id');
|
|
}
|
|
}
|