File: D:/HostingSpaces/SBogers10/stempel.komma.pro/app/Komma/Globalization/Countries/CountryService.php
<?php
namespace App\Komma\Globalization\Countries;
use App\Komma\Globalization\Countries\Models\Country;
class CountryService
{
public function countriesForCheckout()
{
// Get all countries
$countries = Country::all();
// Create array
$checkoutCountries = [];
foreach($countries as $country)
{
if(\Lang::has('countries.' . $country->iso_2))
{
$checkoutCountries[$country->iso_2] = \Lang::get('countries.' . $country->iso_2);
}
}
asort($checkoutCountries);
return $checkoutCountries;
}
public function getCountryByIso2($iso_2) : Country
{
return $country = Country::where('iso_2', $iso_2)
->first();
}
}