2014-07-31 15:01:52 -05:00
|
|
|
<?php
|
2014-08-09 05:23:42 -05:00
|
|
|
use Carbon\Carbon;
|
2014-07-31 15:01:52 -05:00
|
|
|
use LaravelBook\Ardent\Ardent as Ardent;
|
|
|
|
|
2014-08-02 00:34:38 -05:00
|
|
|
/**
|
|
|
|
* Piggybank
|
|
|
|
*
|
2014-08-09 05:23:42 -05:00
|
|
|
* @property integer $id
|
2014-08-02 00:34:38 -05:00
|
|
|
* @property \Carbon\Carbon $created_at
|
|
|
|
* @property \Carbon\Carbon $updated_at
|
2014-08-09 05:23:42 -05:00
|
|
|
* @property integer $account_id
|
2014-08-02 00:34:38 -05:00
|
|
|
* @property \Carbon\Carbon $targetdate
|
2014-08-09 05:23:42 -05:00
|
|
|
* @property string $name
|
|
|
|
* @property float $amount
|
|
|
|
* @property float $target
|
|
|
|
* @property integer $order
|
|
|
|
* @property-read \Account $account
|
2014-08-02 00:34:38 -05:00
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereId($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereCreatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereUpdatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereAccountId($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetdate($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereName($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereAmount($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTarget($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
2014-08-13 00:02:13 -05:00
|
|
|
* @property float $targetamount
|
|
|
|
* @property string $startdate
|
|
|
|
* @property boolean $repeats
|
|
|
|
* @property string $rep_length
|
|
|
|
* @property integer $rep_times
|
|
|
|
* @property string $reminder
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetamount($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereStartdate($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepeats($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepLength($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepTimes($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
2014-08-02 00:34:38 -05:00
|
|
|
*/
|
2014-07-31 15:01:52 -05:00
|
|
|
class Piggybank extends Ardent
|
|
|
|
{
|
2014-08-13 13:36:32 -05:00
|
|
|
public $fillable = [
|
|
|
|
'name',
|
|
|
|
'account_id',
|
|
|
|
'targetamount',
|
|
|
|
'repeats',
|
|
|
|
'rep_times',
|
|
|
|
'order'
|
|
|
|
];
|
|
|
|
|
2014-07-31 15:01:52 -05:00
|
|
|
public static $rules
|
|
|
|
= [
|
2014-08-13 00:02:13 -05:00
|
|
|
'account_id' => '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',
|
2014-07-31 15:01:52 -05:00
|
|
|
];
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-08-09 05:23:42 -05:00
|
|
|
public static function factory()
|
|
|
|
{
|
|
|
|
$start = new Carbon;
|
|
|
|
$start->endOfMonth();
|
2014-08-13 00:02:13 -05:00
|
|
|
$today = new Carbon;
|
2014-08-09 05:23:42 -05:00
|
|
|
|
|
|
|
return [
|
|
|
|
'account_id' => 'factory|Account',
|
2014-08-13 00:02:13 -05:00
|
|
|
'name' => 'string',
|
|
|
|
'targetamount' => 'required|min:0',
|
|
|
|
'targetdate' => $start,
|
|
|
|
'startdate' => $today,
|
|
|
|
'repeats' => 0,
|
|
|
|
'rep_length' => null,
|
|
|
|
'rep_times' => 0,
|
|
|
|
'reminder' => null,
|
|
|
|
'order' => 1,
|
2014-08-09 05:23:42 -05:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-07-31 15:01:52 -05:00
|
|
|
public function account()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('Account');
|
|
|
|
}
|
|
|
|
|
2014-08-13 00:02:13 -05:00
|
|
|
public function piggybankrepetitions() {
|
|
|
|
return $this->hasMany('PiggybankRepetition');
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-08-02 00:34:38 -05:00
|
|
|
public function getDates()
|
|
|
|
{
|
2014-08-10 11:22:42 -05:00
|
|
|
return ['created_at', 'updated_at', 'targetdate'];
|
2014-08-02 00:34:38 -05:00
|
|
|
}
|
|
|
|
|
2014-07-31 15:01:52 -05:00
|
|
|
}
|