ldc-web/app/Http/Requests/GitReposStoreRequest.php
Vincent BRIDIER e4ffc0a0dc - Add Git Repos Management
- Remove Git Repos from Projects
2021-08-10 09:09:56 +02:00

46 lines
1,020 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 bool
*/
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);
})
],
];
}
}