Files
firefly-iii/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php

65 lines
1.9 KiB
PHP
Raw Normal View History

2020-07-19 17:43:12 +02:00
<?php
2020-07-19 17:43:12 +02:00
/**
* AutocompleteRequest.php
* Copyright (c) 2020 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.
*
* This program 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 Affero General Public License for more details.
*
* 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/>.
*/
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Autocomplete;
2025-01-03 09:15:52 +01:00
use FireflyIII\Enums\AccountTypeEnum;
2020-11-08 13:36:13 +01:00
use FireflyIII\Support\Request\ChecksLogin;
2020-07-19 17:43:12 +02:00
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
/**
* Class AutocompleteRequest
*/
class AutocompleteRequest extends FormRequest
{
2022-10-30 14:23:00 +01:00
use ChecksLogin;
2023-11-04 14:18:49 +01:00
use ConvertsDataTypes;
2020-07-19 17:43:12 +02:00
public function getData(): array
{
2022-05-02 19:35:35 +02:00
$types = $this->convertString('types');
2020-07-19 17:43:12 +02:00
$array = [];
if ('' !== $types) {
$array = explode(',', $types);
}
2020-10-17 09:02:52 +02:00
// remove 'initial balance' from allowed types. its internal
2025-01-03 09:15:52 +01:00
$array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::RECONCILIATION->value]);
2020-10-17 09:02:52 +02:00
2020-07-19 17:43:12 +02:00
return [
'types' => $array,
2022-05-02 19:35:35 +02:00
'query' => $this->convertString('query'),
2021-12-28 20:42:50 +01:00
'date' => $this->getCarbonDate('date'),
2020-07-19 17:43:12 +02:00
];
}
public function rules(): array
{
2020-07-21 06:14:47 +02:00
return [
'date' => 'date|after:1900-01-01|before:2099-12-31',
2020-07-21 06:14:47 +02:00
];
2020-07-19 17:43:12 +02:00
}
}