firefly-iii/app/models/Transaction.php

91 lines
3.5 KiB
PHP
Raw Normal View History

<?php
use LaravelBook\Ardent\Ardent;
2014-07-15 15:16:29 -05:00
/**
* Transaction
*
2014-08-28 00:53:54 -05:00
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $account_id
* @property integer $piggybank_id
* @property integer $transaction_journal_id
* @property string $description
* @property float $amount
* @property-read \Account $account
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
2014-07-15 15:16:29 -05:00
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
2014-08-28 00:53:54 -05:00
* @property-read \Piggybank $piggybank
* @property-read \TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value)
2014-07-15 15:16:29 -05:00
*/
class Transaction extends Ardent
{
public static $rules
= [
'account_id' => 'numeric|required|exists:accounts,id',
'piggybank_id' => 'numeric|exists:piggybanks,id',
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
'description' => 'between:1,255',
'amount' => 'required|between:-65536,65536|not_in:0,0.00',
];
2014-08-10 11:22:42 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
{
return $this->belongsTo('Account');
}
2014-08-10 11:22:42 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
2014-08-10 11:22:42 -05:00
*/
public function budgets()
{
return $this->belongsToMany('Budget', 'component_transaction', 'transaction_id', 'component_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function categories()
{
return $this->belongsToMany('Category', 'component_transaction', 'transaction_id', 'component_id');
}
2014-08-10 11:22:42 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function components()
{
return $this->belongsToMany('Component');
}
2014-08-10 11:22:42 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
2014-08-10 11:22:42 -05:00
*/
public function piggybank()
{
return $this->belongsTo('Piggybank');
}
2014-08-10 11:22:42 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
2014-08-10 11:22:42 -05:00
*/
public function transactionJournal()
{
return $this->belongsTo('TransactionJournal');
}
}