2014-07-05 12:44:26 -05:00
|
|
|
<?php
|
|
|
|
|
2014-12-16 14:41:16 -06:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
2014-12-20 08:00:53 -06:00
|
|
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
2014-12-20 09:06:25 -06:00
|
|
|
use \Watson\Validating\ValidatingTrait;
|
2014-12-13 14:59:02 -06:00
|
|
|
/**
|
|
|
|
* Class Budget
|
|
|
|
*/
|
2014-12-17 13:47:46 -06:00
|
|
|
class Budget extends Eloquent
|
2014-07-20 11:24:27 -05:00
|
|
|
{
|
2014-12-20 09:06:25 -06:00
|
|
|
use SoftDeletingTrait, ValidatingTrait;
|
2014-12-17 13:47:46 -06:00
|
|
|
protected $fillable = ['name', 'user_id'];
|
2014-12-20 09:06:25 -06:00
|
|
|
protected $rules = [
|
|
|
|
'user_id' => 'exists:users,id|required',
|
|
|
|
'name' => 'required|between:1,100|alphabasic',
|
|
|
|
];
|
2014-07-05 12:44:26 -05:00
|
|
|
|
2014-12-13 14:59:02 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
|
|
|
*/
|
2014-11-21 04:11:52 -06:00
|
|
|
public function limitrepetitions()
|
|
|
|
{
|
2014-12-17 13:47:46 -06:00
|
|
|
return $this->hasManyThrough('LimitRepetition', 'BudgetLimit', 'budget_id');
|
2014-11-21 04:11:52 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
2014-12-13 14:59:02 -06:00
|
|
|
public function budgetlimits()
|
2014-07-20 11:24:27 -05:00
|
|
|
{
|
2014-12-26 15:59:13 -06:00
|
|
|
return $this->hasMany('BudgetLimit');
|
2014-12-17 13:47:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
|
|
|
public function transactionjournals()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('TransactionJournal', 'budget_transaction_journal', 'budget_id');
|
2014-07-20 11:24:27 -05:00
|
|
|
}
|
|
|
|
|
2014-12-17 13:47:46 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('User');
|
|
|
|
}
|
2014-07-05 12:44:26 -05:00
|
|
|
|
2015-01-01 23:16:49 -06:00
|
|
|
}
|