mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 11:20:39 -06:00
5c7df5c04d
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
85 lines
2.5 KiB
PHP
85 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* TransactionType.php
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
*
|
|
* This software may be modified and distributed under the terms
|
|
* of the MIT license. See the LICENSE file for details.
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
namespace FireflyIII\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* FireflyIII\Models\TransactionType
|
|
*
|
|
* @property integer $id
|
|
* @property \Carbon\Carbon $created_at
|
|
* @property \Carbon\Carbon $updated_at
|
|
* @property \Carbon\Carbon $deleted_at
|
|
* @property string $type
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals
|
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereId($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereDeletedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereType($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class TransactionType extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
const WITHDRAWAL = 'Withdrawal';
|
|
const DEPOSIT = 'Deposit';
|
|
const TRANSFER = 'Transfer';
|
|
const OPENING_BALANCE = 'Opening balance';
|
|
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isDeposit()
|
|
{
|
|
return $this->type === TransactionType::DEPOSIT;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isOpeningBalance()
|
|
{
|
|
return $this->type === TransactionType::OPENING_BALANCE;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isTransfer()
|
|
{
|
|
return $this->type === TransactionType::TRANSFER;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isWithdrawal()
|
|
{
|
|
return $this->type === TransactionType::WITHDRAWAL;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function transactionJournals()
|
|
{
|
|
return $this->hasMany('FireflyIII\Models\TransactionJournal');
|
|
}
|
|
}
|