2014-07-17 13:52:54 -05:00
|
|
|
<?php
|
|
|
|
|
2014-07-30 15:31:35 -05:00
|
|
|
use Carbon\Carbon;
|
2014-12-26 15:59:13 -06:00
|
|
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
2014-07-30 15:31:35 -05:00
|
|
|
use Illuminate\Database\QueryException;
|
2014-12-06 05:12:55 -06:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2014-12-26 15:59:13 -06:00
|
|
|
|
2014-12-13 14:59:02 -06:00
|
|
|
/**
|
|
|
|
* Class Limit
|
|
|
|
*/
|
|
|
|
class BudgetLimit extends Eloquent
|
2014-07-17 13:52:54 -05:00
|
|
|
{
|
|
|
|
|
2014-12-06 05:12:55 -06:00
|
|
|
use ValidatingTrait;
|
2014-07-17 13:52:54 -05:00
|
|
|
public static $rules
|
2014-11-18 02:47:50 -06:00
|
|
|
= [
|
2014-12-26 15:59:13 -06:00
|
|
|
'budget_id' => 'required|exists:budgets,id',
|
|
|
|
'startdate' => 'required|date',
|
|
|
|
'amount' => 'numeric|required|min:0.01',
|
|
|
|
'repeats' => 'required|boolean',
|
|
|
|
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly'
|
2014-07-17 13:52:54 -05:00
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-07-30 15:31:35 -05:00
|
|
|
public function budget()
|
|
|
|
{
|
2014-12-26 15:59:13 -06:00
|
|
|
return $this->belongsTo('Budget');
|
2014-07-30 15:31:35 -05:00
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
2014-07-22 23:57:51 -05:00
|
|
|
public function limitrepetitions()
|
|
|
|
{
|
2014-07-20 11:24:27 -05:00
|
|
|
return $this->hasMany('LimitRepetition');
|
|
|
|
}
|
|
|
|
|
2014-08-09 12:10:31 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-07-17 13:52:54 -05:00
|
|
|
public function getDates()
|
|
|
|
{
|
|
|
|
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-01 23:16:49 -06:00
|
|
|
}
|