2014-06-29 15:12:33 -05:00
|
|
|
<?php
|
2014-11-12 07:38:32 -06:00
|
|
|
use FireflyIII\Shared\SingleTableInheritanceEntity;
|
2014-06-29 15:12:33 -05:00
|
|
|
|
2014-07-15 15:16:29 -05:00
|
|
|
/**
|
|
|
|
* Component
|
|
|
|
*
|
2014-08-31 00:32:48 -05:00
|
|
|
* @property integer $id
|
|
|
|
* @property \Carbon\Carbon $created_at
|
|
|
|
* @property \Carbon\Carbon $updated_at
|
|
|
|
* @property string $name
|
|
|
|
* @property integer $user_id
|
|
|
|
* @property string $class
|
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
2014-07-15 15:16:29 -05:00
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
2014-08-31 00:32:48 -05:00
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
|
|
|
* @property-read \User $user
|
2014-11-10 11:38:58 -06:00
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereId($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereCreatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereUpdatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereName($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereUserId($value)
|
|
|
|
* @method static \Illuminate\Database\Query\Builder|\Component whereClass($value)
|
2014-07-15 15:16:29 -05:00
|
|
|
*/
|
2014-08-23 15:32:12 -05:00
|
|
|
class Component extends SingleTableInheritanceEntity
|
2014-06-29 15:12:33 -05:00
|
|
|
{
|
2014-07-05 12:44:26 -05:00
|
|
|
|
2014-07-05 09:19:15 -05:00
|
|
|
public static $rules
|
|
|
|
= [
|
2014-07-20 11:24:27 -05:00
|
|
|
'user_id' => 'exists:users,id|required',
|
2014-09-20 01:39:24 -05:00
|
|
|
'name' => ['required', 'between:1,100','min:1', 'alphabasic'],
|
2014-07-20 11:24:27 -05:00
|
|
|
'class' => 'required',
|
|
|
|
];
|
2014-07-06 08:18:11 -05:00
|
|
|
protected $table = 'components';
|
|
|
|
protected $subclassField = 'class';
|
2014-09-20 01:39:24 -05:00
|
|
|
protected $fillable = ['name','user_id'];
|
|
|
|
|
2014-07-05 09:19:15 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
2014-07-20 11:24:27 -05:00
|
|
|
public function limits()
|
|
|
|
{
|
2014-08-09 12:10:31 -05:00
|
|
|
return $this->hasMany('Limit');
|
2014-07-17 13:52:54 -05:00
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
2014-07-05 12:44:26 -05:00
|
|
|
public function transactionjournals()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('TransactionJournal');
|
|
|
|
}
|
2014-06-29 15:12:33 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
2014-08-09 12:10:31 -05:00
|
|
|
public function transactions()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('Transaction');
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-06-29 15:12:33 -05:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('User');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|