本文整理汇总了PHP中app\models\Country::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::where方法的具体用法?PHP Country::where怎么用?PHP Country::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Country
的用法示例。
在下文中一共展示了Country::where方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Empty the countries table
DB::table('countries')->delete();
if (DB::table('countries')->count() == 0) {
//Get all of the countries
$countries = Countries::getList();
foreach ($countries as $countryId => $country) {
DB::table('countries')->insert(array('id' => $countryId, 'capital' => isset($country['capital']) ? $country['capital'] : null, 'citizenship' => isset($country['citizenship']) ? $country['citizenship'] : null, 'country_code' => $country['country-code'], 'currency' => isset($country['currency']) ? $country['currency'] : null, 'currency_code' => isset($country['currency_code']) ? $country['currency_code'] : null, 'currency_sub_unit' => isset($country['currency_sub_unit']) ? $country['currency_sub_unit'] : null, 'full_name' => isset($country['full_name']) ? $country['full_name'] : null, 'iso_3166_2' => $country['iso_3166_2'], 'iso_3166_3' => $country['iso_3166_3'], 'name' => $country['name'], 'region_code' => $country['region-code'], 'sub_region_code' => $country['sub-region-code'], 'eea' => (bool) $country['eea']));
}
}
// Source: http://www.bitboost.com/ref/international-address-formats.html
// Source: https://en.wikipedia.org/wiki/Linguistic_issues_concerning_the_euro
$countries = ['AR' => ['swap_postal_code' => true], 'AT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'BE' => ['swap_postal_code' => true], 'BG' => ['swap_currency_symbol' => true], 'CH' => ['swap_postal_code' => true], 'CZ' => ['swap_currency_symbol' => true], 'DE' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'DK' => ['swap_postal_code' => true], 'EE' => ['swap_currency_symbol' => true], 'ES' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'FI' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'FR' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'GR' => ['swap_currency_symbol' => true], 'HR' => ['swap_currency_symbol' => true], 'HU' => ['swap_currency_symbol' => true], 'GL' => ['swap_postal_code' => true], 'IE' => ['thousand_separator' => ',', 'decimal_separator' => '.'], 'IL' => ['swap_postal_code' => true], 'IS' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'IT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'JP' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'LT' => ['swap_currency_symbol' => true], 'LU' => ['swap_postal_code' => true], 'MY' => ['swap_postal_code' => true], 'MX' => ['swap_postal_code' => true], 'NL' => ['swap_postal_code' => true], 'PL' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'PT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'RO' => ['swap_currency_symbol' => true], 'SE' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'SI' => ['swap_currency_symbol' => true], 'SK' => ['swap_currency_symbol' => true], 'UY' => ['swap_postal_code' => true]];
foreach ($countries as $code => $data) {
$country = Country::where('iso_3166_2', '=', $code)->first();
if (isset($data['swap_postal_code'])) {
$country->swap_postal_code = true;
}
if (isset($data['swap_currency_symbol'])) {
$country->swap_currency_symbol = true;
}
if (isset($data['thousand_separator'])) {
$country->thousand_separator = $data['thousand_separator'];
}
if (isset($data['decimal_separator'])) {
$country->decimal_separator = $data['decimal_separator'];
}
$country->save();
}
}
示例2: create
/**
* Create a new User.
*
* @param array $attributes
* @return mixed
*/
public function create($attributes = array())
{
$country = Country::where('id', array_get($attributes, 'country'));
if ($country->exists()) {
array_set($attributes, 'country', $country->first()->id);
$user = User::create($attributes);
Event::fire(new EmailUpdatedEvent($user));
return $user;
}
return false;
}
示例3: issue
public function issue()
{
// 1 byte = 2^8 bits = 16^2 bits = 2 hex characters
$key = bin2hex(random_bytes(config('osu.user.verification_key_length_hex') / 2));
$user = $this->user;
$email = $user->user_email;
$to = $user->user_email;
$this->request->session()->put('verification_key', $key);
$this->request->session()->put('verification_expire_date', Carbon::now()->addHours(5));
$this->request->session()->put('verification_tries', 0);
$requestCountry = Country::where('acronym', $this->request->header('CF_IPCOUNTRY'))->pluck('name')->first();
Mail::queue(['text' => i18n_view('emails.user_verification')], compact('key', 'user', 'requestCountry'), function ($message) use($to) {
$message->to($to);
$message->subject(trans('user_verification.email.subject'));
});
}
示例4: handle
public function handle(UserCreateCommand $command)
{
$reader = new Reader(storage_path() . '/geolite2city.mmdb');
$ip = null;
if (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$country = null;
$timezone = null;
if (!is_null($ip)) {
$record = $reader->get($ip);
$timezone = Timezone::firstOrCreate(['name' => $record["location"]["time_zone"]]);
$countryCode = $record["country"]["iso_code"];
$country = Country::where('iso_3166_2', $countryCode)->first();
}
$user = new User(['username' => $command->username, 'email' => $command->email, 'country_id' => is_null($country) ? null : $country->id, 'timezone_id' => is_null($timezone) ? null : $timezone->id]);
$user->password = $command->password;
$user->save();
\Event::fire(new UserCreatedEvent($user));
return $user->id;
}
示例5: updateLocalization
private function updateLocalization()
{
// Source: http://www.bitboost.com/ref/international-address-formats.html
// Source: https://en.wikipedia.org/wiki/Linguistic_issues_concerning_the_euro
$countries = ['AR' => ['swap_postal_code' => true], 'AT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'BE' => ['swap_postal_code' => true], 'BG' => ['swap_currency_symbol' => true], 'CH' => ['swap_postal_code' => true], 'CZ' => ['swap_currency_symbol' => true], 'DE' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'DK' => ['swap_postal_code' => true], 'EE' => ['swap_currency_symbol' => true], 'ES' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'FI' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'FR' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'GR' => ['swap_currency_symbol' => true], 'HR' => ['swap_currency_symbol' => true], 'HU' => ['swap_currency_symbol' => true], 'GL' => ['swap_postal_code' => true], 'IE' => ['thousand_separator' => ',', 'decimal_separator' => '.'], 'IL' => ['swap_postal_code' => true], 'IS' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'IT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'LT' => ['swap_currency_symbol' => true], 'LU' => ['swap_postal_code' => true], 'MY' => ['swap_postal_code' => true], 'MX' => ['swap_postal_code' => true], 'NL' => ['swap_postal_code' => true], 'PL' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'PT' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'RO' => ['swap_currency_symbol' => true], 'SE' => ['swap_postal_code' => true, 'swap_currency_symbol' => true], 'SI' => ['swap_currency_symbol' => true], 'SK' => ['swap_currency_symbol' => true], 'UY' => ['swap_postal_code' => true]];
foreach ($countries as $code => $data) {
$country = Country::where('iso_3166_2', '=', $code)->first();
if (isset($data['swap_postal_code'])) {
$country->swap_postal_code = true;
}
if (isset($data['swap_currency_symbol'])) {
$country->swap_currency_symbol = true;
}
if (isset($data['thousand_separator'])) {
$country->thousand_separator = $data['thousand_separator'];
}
if (isset($data['decimal_separator'])) {
$country->decimal_separator = $data['decimal_separator'];
}
$country->save();
}
}
示例6: getCountryId
public static function getCountryId($country)
{
$id = Country::where('country_name', 'like', $country)->firstOrFail();
return $id['id'];
}
示例7: updateSwapPostalCode
private function updateSwapPostalCode()
{
// Source: http://www.bitboost.com/ref/international-address-formats.html
$countries = ['AR', 'AT', 'CH', 'BE', 'DE', 'DK', 'ES', 'FI', 'FR', 'GL', 'IL', 'IS', 'IT', 'LU', 'MY', 'MX', 'NL', 'PL', 'PT', 'SE', 'UY'];
for ($i = 0; $i < count($countries); $i++) {
$code = $countries[$i];
$country = Country::where('iso_3166_2', '=', $code)->first();
$country->swap_postal_code = true;
$country->save();
}
}
示例8: listing
public function listing($page, $limit)
{
$response = array('data' => array(), 'paginator' => '');
if (!empty($limit)) {
$countries = Country::paginate($limit);
} else {
$countries = Country::where('id', '>', '0')->get();
}
if (!empty($countries)) {
foreach ($countries as $key => $country) {
$response['data'][] = $this->get($country->id, false);
}
}
if (!empty($limit)) {
$response = Utility::paginator($response, $countries, $limit);
}
return $response;
}
示例9: function
$router->post('/questions/upload', 'QuestionsController@store');
$router->post('/questions/{id}', 'QuestionsController@show');
$router->bind('pagename', function ($id) {
return \AppAdmin\Models\PageName::find($id);
});
$router->bind('categories', function ($id) {
return \App\Models\Category::find($id);
});
$router->bind('tags', function ($id) {
return \App\Models\Tags::find($id);
});
$router->bind('ads', function ($id) {
return \App\Models\Advertisement::find($id);
});
$router->bind('country', function ($title) {
return \App\Models\Country::where('title', '=', $title)->first();
});
/**
* PROFILE
*/
$router->bind('profile', function ($user_name) {
$user = \App\Models\User::where('user_name', $user_name)->first();
if (!$user) {
$user = \App\Models\User::where('user_name', Auth::user()->user_name)->first();
}
return \ZaWeb\Profile\Models\Profile::where('user_id', $user->id)->first();
});
/**
* COMMENTS
*/
Route::model('comments', 'App\\Models\\Comments');
示例10: getCountry
public function getCountry()
{
//return $this->hasOne('App\Models\Country', 'id_Country', 'id_Country');
return Country::where("id_Country", "=", $this->id_Country)->first();
}
示例11: parseTenders
protected function parseTenders(Client $client, Crawler $crawler)
{
$repeatSensor = 0;
$contractsNum = 0;
$crawler->filter('div.registerBox')->each(function (Crawler $node, $i) use($client, &$repeatSensor, &$contractsNum) {
$systemId = str_replace('№ ', '', trim($node->filter('td.descriptTenderTd > dl > dt > a')->text()));
$organizationNode = $node->filter('dd.nameOrganization > a');
$organizationName = trim($organizationNode->text());
$organizationUrl = trim($organizationNode->attr('href'));
//Log::info('Node data', [$node->html()]);
$contractName = trim($node->filter('td.descriptTenderTd > dl > dd')->eq(1)->text());
$contractUrl = $node->filter('td.descriptTenderTd > dl > dt > a')->attr('href');
$contractType = trim($node->filter('td.tenderTd > dl > dt')->eq(0)->text());
$contractStatus = '';
/*Log::info('Обработка нового контракта', [
'org_name' => $organizationName,
'org_url' => $organizationUrl,
'name' => $contractName,
'url' => $contractUrl
]);*/
$contract = Contract::where('system_id', $systemId)->first();
if (!$contract) {
$repeatSensor = 0;
// Search organization in database
$organization = Organization::where('url', $organizationUrl)->first();
if (!$organization) {
//Log::info('Организация не найдена, добавляем в базу.');
$organization = new Organization();
$organization->name = $organizationName;
$organization->url = $organizationUrl;
$this->info($organizationUrl);
$organizationResponse = $client->get($organizationUrl);
$organizationCrawler = new Crawler((string) $organizationResponse->getBody());
//Log::info('Информация по организации загружена.');
// Federal Law 223
if (preg_match("/223\\/ppa/", $organizationUrl)) {
$organizationCrawler->filter('div.noticeTabBoxWrapper > table tr')->each(function (Crawler $row, $j) use(&$organization) {
if ($row->children('td')->count() > 1) {
$nameColumn = trim($row->children('td')->eq(0)->text());
$valueColumn = trim($row->children('td')->eq(1)->text());
if ($valueColumn) {
switch ($nameColumn) {
case 'Уровень организации':
$organization->level = $valueColumn;
break;
case 'ИНН':
$organization->inn = $valueColumn;
break;
case 'КПП':
$organization->kpp = $valueColumn;
break;
case 'ОГРН':
$organization->ogrn = $valueColumn;
break;
case 'ОКАТО':
$organization->okato = $valueColumn;
break;
case 'Адрес (место нахождения)':
$addresses = array_map(function ($value) {
return trim($value);
}, explode(',', $valueColumn));
$address = collect($addresses);
$address->forget('Российская Федерация');
$organization->postal_code = $address[0];
$organization->country_id = 1;
$country = Country::find(1);
if (isset($address[3])) {
$region = Region::where('name', $address[2])->where('country_id', $country->id)->first();
if (!$region) {
$region = Region::create(['country_id' => $country->id, 'name' => $address[2]]);
}
$town = Town::where('name', $address[3])->where('region_id', $region->id)->first();
if (!$town) {
$town = Town::create(['region_id' => $region->id, 'name' => $address[3]]);
}
$organization->region_id = $region->id;
$organization->town_id = $town->id;
}
$organization->address = $valueColumn;
break;
case 'Телефон':
$organization->contact_phone = $valueColumn;
break;
case 'Факс':
$organization->contact_fax = $valueColumn;
break;
case 'Почтовый адрес':
$organization->contact_address = $valueColumn;
break;
case 'Контактное лицо':
$organization->contact_name = $valueColumn;
break;
case 'Адрес электронной почты для системных уведомлений':
$organization->contact_email = $valueColumn;
break;
}
}
}
});
} else {
//.........这里部分代码省略.........