Files
ikea/app/Models/CountryCode.php
Jaroslav Drzik e55e88fa62
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s
fix name of country
2023-12-26 16:03:10 +01:00

54 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CountryCode extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'c_ikea_country_code';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'currency_code';
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
use HasFactory;
protected function active(String $status)
{
return $this->where('status', $status)->get();
}
protected function countryHash()
{
$codes = $this->select('country_name', 'country_code')->get();
return $codes->mapWithKeys(function ($item) {
return [$item['country_name'] => $item['country_code']];
});
}
protected function code_countryHash()
{
$codes = $this->select('country_name', 'country_code')->get();
return $codes->mapWithKeys(function ($item) {
return [$item['country_code'] => $item['country_name']];
});
}
}