akaunting/app/Models/Banking/Reconciliation.php

90 lines
2.2 KiB
PHP
Raw Normal View History

2018-10-27 17:57:40 +03:00
<?php
namespace App\Models\Banking;
2019-11-16 10:21:14 +03:00
use App\Abstracts\Model;
2021-06-18 10:52:20 +03:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2018-10-27 17:57:40 +03:00
class Reconciliation extends Model
{
2021-06-18 10:52:20 +03:00
use HasFactory;
2018-10-27 17:57:40 +03:00
protected $table = 'reconciliations';
protected $dates = ['deleted_at', 'started_at', 'ended_at'];
/**
* Attributes that should be mass-assignable.
*
* @var array
*/
protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'transactions', 'reconciled', 'created_from', 'created_by'];
2018-10-27 17:57:40 +03:00
2020-11-13 15:15:27 +03:00
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
2023-03-16 16:36:13 +03:00
'closing_balance' => 'double',
'reconciled' => 'boolean',
'transactions' => 'array',
'deleted_at' => 'datetime',
2020-11-13 15:15:27 +03:00
];
2018-10-27 17:57:40 +03:00
/**
* Sortable columns.
*
* @var array
*/
public $sortable = ['created_at', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled'];
public function account()
{
return $this->belongsTo('App\Models\Banking\Account');
}
2021-06-18 10:52:20 +03:00
2022-06-01 10:15:55 +03:00
/**
* Get the line actions.
*
* @return array
*/
public function getLineActionsAttribute()
{
$actions = [];
$actions[] = [
'title' => trans('general.edit'),
'icon' => 'edit',
'url' => route('reconciliations.edit', $this->id),
'permission' => 'update-banking-reconciliations',
2022-09-06 13:54:56 +03:00
'attributes' => [
'id' => 'index-line-actions-edit-reconciliation-' . $this->id,
],
2022-06-01 10:15:55 +03:00
];
$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'reconciliations.destroy',
'permission' => 'delete-banking-reconciliations',
2022-09-06 13:54:56 +03:00
'attributes' => [
'id' => 'index-line-actions-delete-reconciliation-' . $this->id,
],
2022-06-01 10:15:55 +03:00
'model' => $this,
];
return $actions;
}
2021-06-18 10:52:20 +03:00
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Database\Factories\Reconciliation::new();
}
2018-10-27 17:57:40 +03:00
}