. */ declare(strict_types=1); namespace FireflyIII\Http\Requests; use FireflyIII\Models\PiggyBank; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; /** * Class PiggyBankFormRequest. */ class PiggyBankUpdateRequest 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->nlString('notes'), 'object_group_title' => $this->string('object_group'), ]; } /** * Rules for this request. * * @return array */ public function rules(): array { /** @var PiggyBank $piggy */ $piggy = $this->route()->parameter('piggyBank'); return [ 'name' => sprintf('required|between:1,255|uniquePiggyBankForUser:%d', $piggy->id), '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', ]; } }