firefly-iii/app/models/Component.php
2014-07-15 22:16:29 +02:00

55 lines
1.7 KiB
PHP

<?php
/**
* Component
*
* @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|\Transaction[] $transactions
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
* @property-read \User $user
* @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)
*/
class Component extends Firefly\Database\SingleTableInheritanceEntity
{
public static $rules
= [
'user_id' => 'exists:users,id|required',
'name' => 'required|between:1,255',
'class' => 'required',
];
protected $table = 'components';
protected $subclassField = 'class';
public static $factory = [
'name' => 'string',
'user_id' => 'factory|User',
];
public function transactions()
{
return $this->belongsToMany('Transaction');
}
public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal');
}
public function user()
{
return $this->belongsTo('User');
}
}