Files
firefly-iii/app/Api/V1/Requests/RecurrenceUpdateRequest.php

79 lines
2.2 KiB
PHP
Raw Normal View History

2018-06-29 19:27:07 +02:00
<?php
/**
* RecurrenceUpdateRequest.php
2018-06-29 19:27:07 +02:00
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests;
2018-07-05 18:02:02 +02:00
use FireflyIII\Validation\RecurrenceValidation;
use FireflyIII\Validation\TransactionValidation;
2018-06-29 19:27:07 +02:00
use Illuminate\Validation\Validator;
/**
* Class RecurrenceUpdateRequest
2018-06-29 19:27:07 +02:00
*/
class RecurrenceUpdateRequest extends Request
2018-06-29 19:27:07 +02:00
{
2018-07-05 18:02:02 +02:00
use RecurrenceValidation, TransactionValidation;
2018-06-29 19:27:07 +02:00
/**
* Authorize logged in users.
*
2018-06-29 19:27:07 +02:00
* @return bool
*/
public function authorize(): bool
{
// Only allow authenticated users
return auth()->check();
}
/**
* The rules that the incoming request must be matched against.
*
2018-06-29 19:27:07 +02:00
* @return array
*/
public function rules(): array
{
2019-06-02 06:39:54 +02:00
return $this->rulesRecurrence();
2018-06-29 19:27:07 +02:00
}
/**
* Configure the validator instance.
*
* @param Validator $validator
2018-06-29 19:27:07 +02:00
*
* @return void
*/
public function withValidator(Validator $validator): void
{
$validator->after(
function (Validator $validator) {
2018-07-05 18:02:02 +02:00
$this->validateOneTransaction($validator);
$this->validateOneRepetition($validator);
$this->validateRecurrenceRepetition($validator);
$this->validateRepetitionMoment($validator);
$this->validateForeignCurrencyInformation($validator);
2018-06-29 19:27:07 +02:00
$this->validateAccountInformation($validator);
}
);
}
}