invoiceninja/app/Models/AccountGatewaySettings.php

71 lines
1.3 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Models;
2016-09-15 13:41:09 +03:00
2017-03-14 23:27:09 +02:00
use Utils;
2016-09-15 13:41:09 +03:00
/**
2017-01-30 21:40:43 +02:00
* Class AccountGatewaySettings.
2016-09-15 13:41:09 +03:00
*/
class AccountGatewaySettings extends EntityModel
{
/**
* @var array
*/
protected $dates = ['updated_at'];
2017-03-14 15:18:31 +02:00
/**
* @var array
*/
protected $fillable = [
'fee_amount',
'fee_percent',
'fee_tax_name1',
'fee_tax_rate1',
'fee_tax_name2',
'fee_tax_rate2',
];
2016-09-15 13:41:09 +03:00
/**
* @var bool
*/
protected static $hasPublicId = false;
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function gatewayType()
{
return $this->belongsTo('App\Models\GatewayType');
}
public function setCreatedAtAttribute($value)
{
// to Disable created_at
}
2017-03-14 23:27:09 +02:00
public function areFeesEnabled()
{
return floatval($this->fee_amount) || floatval($this->fee_percent);
}
public function feesToString()
{
$parts = [];
if (floatval($this->fee_amount)) {
$parts[] = Utils::formatMoney($this->fee_amount);
}
if (floatval($this->fee_percent)) {
$parts[] = $this->fee_percent . '%';
}
if (floatval($this->fee_tax_rate1) || floatval($this->fee_tax_rate1)) {
$parts[] = trans('texts.tax');
}
return join(' + ', $parts);
}
2016-09-15 13:41:09 +03:00
}