'required|exists:accounts,id', 'name' => 'required|between:1,255', 'targetamount' => 'required|min:0', 'targetdate' => 'date', 'startdate' => 'date', 'repeats' => 'required|between:0,1', 'rep_length' => 'in:day,week,month,year', 'rep_times' => 'required|min:0|max:100', 'reminder' => 'in:day,week,month,year', 'order' => 'required:min:1', ]; /** * @return array */ public static function factory() { $start = new Carbon; $start->endOfMonth(); $today = new Carbon; return [ 'account_id' => 'factory|Account', 'name' => 'string', 'targetamount' => 'required|min:0', 'targetdate' => $start, 'startdate' => $today, 'repeats' => 0, 'rep_length' => null, 'rep_times' => 0, 'reminder' => null, 'order' => 1, ]; } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function account() { return $this->belongsTo('Account'); } public function piggybankrepetitions() { return $this->hasMany('PiggybankRepetition'); } /** * @return array */ public function getDates() { return ['created_at', 'updated_at', 'targetdate']; } }