feat: implement currency rates tracking with models, migrations and views
هذا الالتزام موجود في:
32
app/Models/City.php
Normal file
32
app/Models/City.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\CityFactory> */
|
||||
use HasFactory;
|
||||
|
||||
const SANAA = 'sanaa';
|
||||
|
||||
const ADEN = 'aden';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'label',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all supported cities
|
||||
*/
|
||||
public static function supportedCities(): array
|
||||
{
|
||||
return [
|
||||
self::SANAA,
|
||||
self::ADEN,
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Models/Currency.php
Normal file
36
app/Models/Currency.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\CurrencyFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The supported currency codes.
|
||||
*/
|
||||
const USD = 'USD';
|
||||
|
||||
const SAR = 'SAR';
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'symbol',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all supported currency codes
|
||||
*/
|
||||
public static function supportedCurrencies(): array
|
||||
{
|
||||
return [
|
||||
self::USD,
|
||||
self::SAR,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Models/Rate.php
Normal file
33
app/Models/Rate.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Rate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'currency_id',
|
||||
'city_id',
|
||||
'buy_price',
|
||||
'sell_price',
|
||||
'date',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date:Y-m-d',
|
||||
];
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم