akaunting/app/Models/Banking/Transfer.php

59 lines
1.5 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Models\Banking;
2019-11-16 10:21:14 +03:00
use App\Abstracts\Model;
2017-09-14 22:21:00 +03:00
use App\Traits\Currencies;
2020-10-14 17:07:59 +03:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2017-09-14 22:21:00 +03:00
class Transfer extends Model
{
2020-10-14 17:07:59 +03:00
use HasFactory, Currencies;
2017-09-14 22:21:00 +03:00
protected $table = 'transfers';
/**
* Attributes that should be mass-assignable.
*
* @var array
*/
2019-11-16 10:21:14 +03:00
protected $fillable = ['company_id', 'expense_transaction_id', 'income_transaction_id'];
2017-09-14 22:21:00 +03:00
/**
* Sortable columns.
*
* @var array
*/
2019-11-16 10:21:14 +03:00
public $sortable = ['expense.paid_at', 'expense.amount', 'expense.name', 'income.name'];
2017-09-14 22:21:00 +03:00
2019-11-16 10:21:14 +03:00
public function expense_transaction()
2017-09-14 22:21:00 +03:00
{
2019-11-16 10:21:14 +03:00
return $this->belongsTo('App\Models\Banking\Transaction', 'expense_transaction_id');
2017-09-14 22:21:00 +03:00
}
2019-11-16 10:21:14 +03:00
public function expense_account()
2017-09-14 22:21:00 +03:00
{
2020-03-23 20:02:00 +03:00
return $this->belongsTo('App\Models\Banking\Account', 'expense_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]);
2017-09-14 22:21:00 +03:00
}
2019-11-16 10:21:14 +03:00
public function income_transaction()
2017-09-14 22:21:00 +03:00
{
2019-11-16 10:21:14 +03:00
return $this->belongsTo('App\Models\Banking\Transaction', 'income_transaction_id');
2017-09-14 22:21:00 +03:00
}
2019-11-16 10:21:14 +03:00
public function income_account()
2017-09-14 22:21:00 +03:00
{
2020-03-23 20:02:00 +03:00
return $this->belongsTo('App\Models\Banking\Account', 'income_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]);
}
2020-10-14 17:07:59 +03:00
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Database\Factories\Transfer::new();
}
2017-09-14 22:21:00 +03:00
}