. */ declare(strict_types=1); namespace FireflyIII\Http\Requests; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; /** * Class PiggyBankStoreRequest. */ class PiggyBankStoreRequest extends FormRequest { use ConvertsDataTypes, ChecksLogin; /** * Returns the data required by the controller. * * @return array */ public function getPiggyBankData(): array { return [ 'name' => $this->string('name'), 'startdate' => $this->date('startdate'), 'account_id' => $this->integer('account_id'), 'targetamount' => $this->string('targetamount'), 'targetdate' => $this->date('targetdate'), 'notes' => $this->stringWithNewlines('notes'), 'object_group_title' => $this->string('object_group'), ]; } /** * Rules for this request. * * @return array */ public function rules(): array { return [ 'name' => 'required|between:1,255|uniquePiggyBankForUser', 'account_id' => 'required|belongsToUser:accounts', 'targetamount' => 'required|numeric|gte:0.01|max:1000000000', 'startdate' => 'date', 'targetdate' => 'date|nullable', 'order' => 'integer|min:1', 'object_group' => 'min:0|max:255', ]; } }