. */ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; /** * Class StoreRequest */ class StoreRequest extends FormRequest { use ChecksLogin; use ConvertsDataTypes; /** * Get all data from the request. */ public function getAll(): array { return [ 'start' => $this->getCarbonDate('start'), 'end' => $this->getCarbonDate('end'), 'amount' => $this->convertString('amount'), 'currency_id' => $this->convertInteger('currency_id'), 'currency_code' => $this->convertString('currency_code'), 'notes' => $this->stringWithNewlines('notes'), ]; } /** * The rules that the incoming request must be matched against. */ public function rules(): array { return [ 'start' => 'required|before:end|date', 'end' => 'required|after:start|date', 'amount' => ['required', new IsValidPositiveAmount()], 'currency_id' => 'numeric|exists:transaction_currencies,id', 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', 'notes' => 'nullable|min:0|max:32768', ]; } }