2014-06-29 15:12:33 -05:00
|
|
|
<?php
|
|
|
|
|
2014-07-15 10:09:59 -05:00
|
|
|
use LaravelBook\Ardent\Ardent;
|
2014-06-29 15:12:33 -05:00
|
|
|
|
2014-07-15 10:09:59 -05:00
|
|
|
|
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
|
|
|
*/
|
2014-07-15 10:09:59 -05:00
|
|
|
class Transaction extends Ardent
|
2014-06-29 15:12:33 -05:00
|
|
|
{
|
2014-07-03 14:31:32 -05:00
|
|
|
public static $rules
|
|
|
|
= [
|
|
|
|
'account_id' => 'numeric|required|exists:accounts,id',
|
2014-08-18 23:57:11 -05:00
|
|
|
'piggybank_id' => 'numeric|exists:piggybanks,id',
|
2014-07-03 14:31:32 -05:00
|
|
|
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
|
|
|
|
'description' => 'between:1,255',
|
2014-07-15 10:09:59 -05:00
|
|
|
'amount' => 'required|between:-65536,65536|not_in:0,0.00',
|
2014-07-03 14:31:32 -05:00
|
|
|
];
|
|
|
|
|
2014-06-29 15:12:33 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-06-29 15:12:33 -05:00
|
|
|
public function account()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('Account');
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
2014-08-16 05:13:50 -05:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2014-08-10 11:22:42 -05:00
|
|
|
*/
|
2014-08-16 05:13:50 -05:00
|
|
|
public function budgets()
|
2014-06-29 15:12:33 -05:00
|
|
|
{
|
2014-08-16 05:13:50 -05:00
|
|
|
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-06-29 15:12:33 -05:00
|
|
|
}
|
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
2014-06-29 15:12:33 -05:00
|
|
|
public function components()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('Component');
|
|
|
|
}
|
2014-07-05 12:44:26 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
2014-08-16 05:13:50 -05:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2014-08-10 11:22:42 -05:00
|
|
|
*/
|
2014-08-16 05:13:50 -05:00
|
|
|
public function piggybank()
|
2014-07-05 12:44:26 -05:00
|
|
|
{
|
2014-08-16 05:13:50 -05:00
|
|
|
return $this->belongsTo('Piggybank');
|
2014-07-05 12:44:26 -05:00
|
|
|
}
|
2014-07-09 06:35:33 -05:00
|
|
|
|
2014-08-10 11:22:42 -05:00
|
|
|
/**
|
2014-08-16 05:13:50 -05:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2014-08-10 11:22:42 -05:00
|
|
|
*/
|
2014-08-16 05:13:50 -05:00
|
|
|
public function transactionJournal()
|
2014-07-05 12:44:26 -05:00
|
|
|
{
|
2014-08-16 05:13:50 -05:00
|
|
|
return $this->belongsTo('TransactionJournal');
|
2014-07-05 12:44:26 -05:00
|
|
|
}
|
2014-06-29 15:12:33 -05:00
|
|
|
}
|