Files
firefly-iii/app/Http/Requests/BillStoreRequest.php

77 lines
2.7 KiB
PHP
Raw Normal View History

2015-02-25 15:19:14 +01:00
<?php
/**
2020-06-30 19:06:05 +02:00
* BillStoreRequest.php
2020-01-31 07:32:04 +01:00
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-10-21 08:40:00 +02:00
*
* This program is distributed in the hope that it will be useful,
2017-10-21 08:40:00 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-10-21 08:40:00 +02:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2017-03-24 15:15:12 +01:00
declare(strict_types=1);
2015-02-25 15:19:14 +01:00
namespace FireflyIII\Http\Requests;
2020-10-24 07:55:09 +02:00
use FireflyIII\Support\Request\ChecksLogin;
2020-07-18 08:42:13 +02:00
use FireflyIII\Support\Request\ConvertsDataTypes;
2020-10-24 07:55:09 +02:00
use Illuminate\Foundation\Http\FormRequest;
2020-07-18 08:36:42 +02:00
2015-02-25 15:19:14 +01:00
/**
2020-06-30 19:06:05 +02:00
* Class BillStoreRequest.
2015-02-25 15:19:14 +01:00
*/
2020-10-24 07:55:09 +02:00
class BillStoreRequest extends FormRequest
2015-02-25 15:19:14 +01:00
{
2020-10-24 07:55:09 +02:00
use ConvertsDataTypes, ChecksLogin;
2015-02-25 15:19:14 +01:00
2015-03-29 11:51:26 +02:00
/**
2018-07-22 08:10:16 +02:00
* Returns the data required by the controller.
*
2015-03-29 11:51:26 +02:00
* @return array
*/
2018-07-08 12:28:42 +02:00
public function getBillData(): array
2015-03-29 11:51:26 +02:00
{
return [
2018-08-19 19:31:21 +02:00
'name' => $this->string('name'),
'amount_min' => $this->string('amount_min'),
'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => '',
'amount_max' => $this->string('amount_max'),
'date' => $this->date('date'),
'repeat_freq' => $this->string('repeat_freq'),
'skip' => $this->integer('skip'),
2019-09-20 06:14:08 +02:00
'notes' => $this->nlString('notes'),
2018-08-19 19:31:21 +02:00
'active' => $this->boolean('active'),
2020-06-30 19:06:05 +02:00
'object_group' => $this->string('object_group'),
2015-03-29 11:51:26 +02:00
];
}
2015-02-25 15:19:14 +01:00
/**
2018-07-22 08:10:16 +02:00
* Rules for this request.
*
2015-02-25 15:19:14 +01:00
* @return array
*/
2018-07-02 20:17:50 +02:00
public function rules(): array
2015-02-25 15:19:14 +01:00
{
2020-06-30 19:06:05 +02:00
return [
'name' => 'required|between:1,255|uniqueObjectForUser:bills,name',
2020-07-06 06:55:27 +02:00
'amount_min' => 'required|numeric|gt:0|max:1000000000',
'amount_max' => 'required|numeric|gt:0|max:1000000000',
2018-04-08 16:27:52 +02:00
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
'date' => 'required|date',
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
'skip' => 'required|between:0,31',
2018-06-24 16:17:42 +02:00
'active' => 'boolean',
2015-02-25 15:19:14 +01:00
];
}
2015-03-29 08:14:32 +02:00
}