mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-29 20:51:09 -04:00
v5.0.0 update
This commit is contained in:
41
app/Models/ExchangeRateLog.php
Normal file
41
app/Models/ExchangeRateLog.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ExchangeRateLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'exchange_rate' => 'float'
|
||||
];
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public static function addExchangeRateLog($model)
|
||||
{
|
||||
$data = [
|
||||
'exchange_rate' => $model->exchange_rate,
|
||||
'company_id' => $model->company_id,
|
||||
'base_currency_id' => $model->currency_id,
|
||||
'currency_id' => CompanySetting::getSetting('currency', $model->company_id),
|
||||
];
|
||||
|
||||
return self::create($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user