46 lines
1,023 B
PHP
46 lines
1,023 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class GitReposStoreRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return Auth::check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'name' => [
|
|
'string',
|
|
'required',
|
|
Rule::unique('git_repos', 'name'),
|
|
],
|
|
'login' => [
|
|
Rule::requiredIf(function () {
|
|
return !is_null($this->password);
|
|
})
|
|
],
|
|
'password' => [
|
|
Rule::requiredIf(function () {
|
|
return !is_null($this->login);
|
|
})
|
|
],
|
|
];
|
|
}
|
|
}
|