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