Fix search, remove, add countries
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\CountryCode;
|
||||
|
||||
class CurrencyRates extends Model
|
||||
{
|
||||
@@ -34,4 +35,16 @@ class CurrencyRates extends Model
|
||||
{
|
||||
return $this->get();
|
||||
}
|
||||
|
||||
protected function rates2EUR(String $status)
|
||||
{
|
||||
$rates = $this->actual("Y")->mapWithKeys(function ($item) {
|
||||
return [$item['currency'] => $item['rate']];
|
||||
});
|
||||
|
||||
return CountryCode::active("Y")->mapWithKeys(function ($item) use ($rates) {
|
||||
if ($item['currency_code'] == "EUR") return [$item["country_code"] => 1.0];
|
||||
return [$item["country_code"] => $rates[$item["currency_code"]]];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user