. */ declare(strict_types=1); namespace FireflyIII\Http\Requests; use FireflyIII\Models\ObjectGroup; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; /** * Class ObjectGroupFormRequest. */ class ObjectGroupFormRequest extends FormRequest { use ChecksLogin; use ConvertsDataTypes; /** * Returns the data required by the controller. * * @return array */ public function getObjectGroupData(): array { return [ 'title' => $this->convertString('title'), ]; } /** * Rules for this request. * * @return array */ public function rules(): array { /** @var ObjectGroup|null $objectGroup */ $objectGroup = $this->route()->parameter('objectGroup'); $titleRule = 'required|between:1,255|uniqueObjectGroup'; if (null !== $objectGroup) { $titleRule = sprintf('required|between:1,255|uniqueObjectGroup:%d', $objectGroup->id); } return [ 'title' => $titleRule, ]; } }