ifnex/04_Laravel/app/Models/ExchangeRateHistory.php
Kazem Alghasi f61de6f3a5 refactor(ui): redesign admin dashboard widgets and exchange service
Refactor the Filament dashboard by replacing the legacy FinanceOverviewWidget
with a new set of specialized widgets:
- DashboardInfoWidget for general information
- ExchangeRateWidget for real-time rate monitoring
- WalletStats for financial overview

Additionally, refactor the ExchangeRateService to improve encapsulation
and clean up the ExchangeRateHistory model by moving business logic
(change calculation and recording) from the model to the service layer.

Changes include:
- Removing deprecated helper methods from ExchangeRateHistory model
- Implementing direct queries in ExchangeRateService to replace model scopes
- Adding support for rate chart data retrieval
- Reordering and updating widget sorting in AdminPanelProvider
2026-08-10 04:08:29 +03:30

34 lines
712 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ExchangeRateHistory extends Model
{
protected $table = 'exchange_rate_history';
protected $fillable = [
'currency_from',
'currency_to',
'old_rate',
'new_rate',
'change_percent',
'change_source',
'changed_by',
'api_source',
'notes',
];
protected $casts = [
'old_rate' => 'decimal:2',
'new_rate' => 'decimal:2',
'change_percent' => 'decimal:4',
];
public function changedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'changed_by');
}
}