mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Remove createItem/updateItem from Item, createTransaction/ completeTransaction/failedTransaction from Transaction, createCustomField/updateCustomField from CustomField, all business methods from ExchangeRateProvider (CRUD + API checks + URL helpers), and validateCredentials/createDisk/updateDisk/updateDefaultDisks/ setAsDefaultDisk from FileDisk. All logic now lives in their respective service classes.
46 lines
997 B
PHP
46 lines
997 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class ExchangeRateProvider extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [
|
|
'id',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'currencies' => 'array',
|
|
'driver_config' => 'array',
|
|
'active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
public function setCurrenciesAttribute($value)
|
|
{
|
|
$this->attributes['currencies'] = json_encode($value);
|
|
}
|
|
|
|
public function setDriverConfigAttribute($value)
|
|
{
|
|
$this->attributes['driver_config'] = json_encode($value);
|
|
}
|
|
|
|
public function scopeWhereCompany($query)
|
|
{
|
|
$query->where('exchange_rate_providers.company_id', request()->header('company'));
|
|
}
|
|
}
|