mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
use LaravelBook\Ardent\Ardent;
|
|
|
|
|
|
class Transaction extends Ardent
|
|
{
|
|
public static $rules
|
|
= [
|
|
'account_id' => 'numeric|required|exists:accounts,id',
|
|
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
|
|
'description' => 'between:1,255',
|
|
'amount' => 'required|between:-65536,65536|not_in:0,0.00',
|
|
];
|
|
|
|
public static $factory
|
|
= [
|
|
'account_id' => 'factory|Account',
|
|
'transaction_journal_id' => 'factory|TransactionJournal',
|
|
'description' => 'string',
|
|
'amount' => 'integer:5'
|
|
];
|
|
|
|
public function account()
|
|
{
|
|
return $this->belongsTo('Account');
|
|
}
|
|
|
|
public function transactionJournal()
|
|
{
|
|
return $this->belongsTo('TransactionJournal');
|
|
}
|
|
|
|
public function components()
|
|
{
|
|
return $this->belongsToMany('Component');
|
|
}
|
|
|
|
public function budgets()
|
|
{
|
|
return $this->belongsToMany('Budget','component_transaction','transaction_id','component_id');
|
|
}
|
|
|
|
public function categories()
|
|
{
|
|
return $this->belongsToMany('Category','component_transaction','transaction_id','component_id');
|
|
}
|
|
}
|