use Ritechoice23\Worldable\Traits\Worldable;
class User extends Model {
use Worldable; // All world features
}Or use specific traits:
use Ritechoice23\Worldable\Traits\{HasCountry, HasCurrency};
class Product extends Model {
use HasCountry, HasCurrency;
}// By name
$user->attachCountry('Nigeria');
$user->attachCity('Lagos');
// By code
$user->attachCountry('NG');
$user->attachCurrency('USD');
// By ID
$user->attachCountry(1);
// With metadata
$user->attachCountry('NG', 'billing', [
'tax_id' => '12345',
'verified_at' => now(),
]);$user->detachCountry('Nigeria');
$user->detachAllCities();// Replace existing with new
$user->syncCountries(['Nigeria', 'Ghana']);if ($user->hasCountry('Nigeria')) {
// User has Nigeria attached
}$countries = $user->countries;
echo $user->country_name; // "Nigeria"
echo $user->country_code; // "NG"// Find users from Nigeria
User::whereFrom('Nigeria')->get();
// Find from continent
User::whereInContinent('Africa')->get();
// Find in city
User::whereInCity('Lagos')->get();
// Find in state
User::whereInState('California')->get();
// Products priced in USD
Product::wherePricedIn('USD')->get();
// Users who speak English
User::whereSpeaks('English')->get();// Attach multiple
$user->attachCountries(['Nigeria', 'Ghana', 'Kenya']);
$user->attachCities(['Lagos', 'Accra'], 'visited');
// Sync (replace all)
$user->syncCountries(['Nigeria', 'Ghana']);$user->attachCountry('Nigeria')
->attachCity('Lagos')
->attachCurrency('NGN')
->attachLanguage('English');