2015-02-05 21:52:16 -06:00
|
|
|
<?php namespace FireflyIII\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2015-02-07 16:19:28 -06:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2015-02-09 00:56:24 -06:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2015-02-05 21:52:16 -06:00
|
|
|
|
2015-02-05 22:04:06 -06:00
|
|
|
class Transaction extends Model
|
|
|
|
{
|
2015-02-09 00:56:24 -06:00
|
|
|
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount'];
|
|
|
|
protected $rules
|
|
|
|
= [
|
|
|
|
'account_id' => 'required|exists:accounts,id',
|
|
|
|
'transaction_journal_id' => 'required|exists:transaction_journals,id',
|
|
|
|
'description' => 'between:1,255',
|
|
|
|
'amount' => 'required|numeric'
|
|
|
|
];
|
|
|
|
use SoftDeletes, ValidatingTrait;
|
2015-02-05 21:52:16 -06:00
|
|
|
|
2015-02-05 22:14:27 -06:00
|
|
|
public function account()
|
|
|
|
{
|
2015-02-05 22:35:00 -06:00
|
|
|
return $this->belongsTo('FireflyIII\Models\Account');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-02-07 06:15:40 -06:00
|
|
|
public function getDates()
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2015-02-07 06:15:40 -06:00
|
|
|
return ['created_at', 'updated_at', 'deleted_at'];
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
2015-02-07 06:15:40 -06:00
|
|
|
|
|
|
|
public function transactionJournal()
|
2015-02-07 05:15:53 -06:00
|
|
|
{
|
2015-02-07 06:15:40 -06:00
|
|
|
return $this->belongsTo('FireflyIII\Models\TransactionJournal');
|
2015-02-07 05:15:53 -06:00
|
|
|
}
|
2015-02-05 21:52:16 -06:00
|
|
|
}
|