Files
firefly-iii/app/Api/V1/Requests/Models/ObjectGroup/UpdateRequest.php

64 lines
1.8 KiB
PHP
Raw Normal View History

2020-06-20 16:28:23 +02:00
<?php
/**
* ObjectGroupUpdateRequest.php
* 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.
*
* 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);
2021-03-06 14:50:48 +01:00
namespace FireflyIII\Api\V1\Requests\Models\ObjectGroup;
2020-06-20 16:28:23 +02:00
2022-10-30 14:44:49 +01:00
use FireflyIII\Models\ObjectGroup;
2020-11-08 13:36:13 +01:00
use FireflyIII\Support\Request\ChecksLogin;
2020-07-18 08:34:00 +02:00
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
2020-06-20 16:28:23 +02:00
/**
2021-03-06 14:50:48 +01:00
* Class UpdateRequest
2020-06-20 16:28:23 +02:00
*/
2021-03-06 14:50:48 +01:00
class UpdateRequest extends FormRequest
2020-06-20 16:28:23 +02:00
{
2022-10-30 14:23:00 +01:00
use ChecksLogin;
2023-11-04 14:18:49 +01:00
use ConvertsDataTypes;
2020-06-20 16:28:23 +02:00
public function getUpdateData(): array
{
2021-03-14 06:20:23 +01:00
$fields = [
2022-05-04 05:53:47 +02:00
'title' => ['title', 'convertString'],
2022-10-01 05:29:42 +02:00
'order' => ['order', 'convertInteger'],
2020-06-20 16:28:23 +02:00
];
2021-03-21 09:15:40 +01:00
2021-03-14 06:20:23 +01:00
return $this->getAllData($fields);
2020-06-20 16:28:23 +02:00
}
/**
* The rules that the incoming request must be matched against.
*/
public function rules(): array
{
2022-10-30 14:44:49 +01:00
/** @var ObjectGroup $objectGroup */
2020-06-20 16:28:23 +02:00
$objectGroup = $this->route()->parameter('objectGroup');
return [
2023-04-26 06:17:04 +02:00
'title' => sprintf('max:1024|min:1|uniqueObjectGroup:%d', $objectGroup->id),
2020-06-20 16:28:23 +02:00
'order' => 'numeric',
];
}
}