本文整理汇总了PHP中app\models\Country类的典型用法代码示例。如果您正苦于以下问题:PHP Country类的具体用法?PHP Country怎么用?PHP Country使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Country类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move
public function move(Country $from, Country $to)
{
if ($from->hasConnectionsTo($to)) {
return new self(ActionType::move(), $from, $to);
}
throw new InvalidActionException('You need to connect your countries to each other before you can move to this country');
}
示例2: actionCreate
/**
* Creates a new Country model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Country();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->code]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: handle
/**
* Execute the job.
*
* @param Country $country
*/
public function handle(Country $country)
{
/**
* Save all Countries
*/
$this->countries->transform(function ($name, $code) use($country) {
return $country->create(compact('name', 'code'));
});
/**
* Announce CountryWasCreated
*/
event(new CountryWasCreated($this->countries->toArray()));
}
示例4: actionIndex
public function actionIndex()
{
$query = Country::find();
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('index', ['countries' => $countries, 'pagination' => $pagination]);
}
示例5: passData
private function passData($id = null)
{
$people = new \App\Models\People();
$address = new \App\Models\Addresses();
$employee = new \App\Models\Employee();
if (!is_null($id)) {
$people = People::findOrNew($id);
$universityHisttory = $people->universityHistory()->get();
$careerHistory = $people->careerHistory()->get();
$employee = $people->employee()->first();
if ($people->address()->first()) {
$address = $people->address()->get()->first();
}
} else {
if (!Session::has('UniversityHistory')) {
Session::set('UniversityHistory', $people->universityHistory()->get());
}
if (!Session::has('CareerHistory')) {
Session::set('CareerHistory', $people->careerHistory()->get());
}
$universityHisttory = Session::get('UniversityHistory');
$careerHistory = Session::get('CareerHistory');
}
$pTitle = PeopleTitle::all()->sortBy("Title_Name")->toArray();
foreach ($pTitle as $peopTitle) {
$peopleTitle[$peopTitle["id_People_Title"]] = $peopTitle["Title_Name"];
}
$employeeType = EmployeeType::getEmployeeTypeOptions();
$countryModel = $address->getCountry();
$regionsOptions = Region::getRegionsOptions();
$countryOptions = Country::getCountriesOptionsByRegion($countryModel->id_Region);
return compact("countryOptions", "regionsOptions", "employeeType", "people", "peopleTitle", "universityHisttory", "careerHistory", "employee", "address");
}
示例6: getLicensePaymentDetails
/**
* @param array $input
* @param Affiliate $affiliate
*
* @return array
*/
private function getLicensePaymentDetails(array $input, Affiliate $affiliate)
{
$country = Country::find($input['country_id']);
$data = ['firstName' => $input['first_name'], 'lastName' => $input['last_name'], 'email' => $input['email'], 'number' => $input['card_number'], 'expiryMonth' => $input['expiration_month'], 'expiryYear' => $input['expiration_year'], 'cvv' => $input['cvv'], 'billingAddress1' => $input['address1'], 'billingAddress2' => $input['address2'], 'billingCity' => $input['city'], 'billingState' => $input['state'], 'billingPostcode' => $input['postal_code'], 'billingCountry' => $country->iso_3166_2, 'shippingAddress1' => $input['address1'], 'shippingAddress2' => $input['address2'], 'shippingCity' => $input['city'], 'shippingState' => $input['state'], 'shippingPostcode' => $input['postal_code'], 'shippingCountry' => $country->iso_3166_2];
$card = new CreditCard($data);
return ['amount' => $affiliate->price, 'card' => $card, 'currency' => 'USD', 'returnUrl' => URL::to('license_complete'), 'cancelUrl' => URL::to('/')];
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('Countries')->delete();
Country::create(['id' => 1, 'country_name' => 'Lithuania']);
Country::create(['id' => 2, 'country_name' => 'Russia']);
Country::create(['id' => 3, 'country_name' => 'Germany']);
}
示例8: 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();
}
}
示例9: passData
private function passData($id = null)
{
$jobs = new \App\Models\Jobs();
if (!is_null($id)) {
$jobs = Jobs::findOrNew($id);
}
$companyPreference = $jobs->getCompanyPreference() ? $jobs->getCompanyPreference() : new \App\Models\CompanyPreference();
$address = $jobs->address()->first() ? $jobs->address()->first() : new \App\Models\Addresses();
$commOrBon = CommisionOrBonus::all()->sortBy("Commission_Or_Bonus")->toArray();
$lns = SupportedLanguages::all()->sortBy("Language_Name")->toArray();
if (sizeof($commOrBon) == 0) {
$commOrBon = new \App\Models\CommisionOrBonus();
}
$tEndUser = TargetEndUser::all()->sortBy("Target_End_User")->toArray();
foreach ($commOrBon as $commisionOrBonusVal) {
$commisionOrBonus[$commisionOrBonusVal["id_Commission_Or_Bonus"]] = $commisionOrBonusVal["Commission_Or_Bonus"];
}
foreach ($tEndUser as $tgEndUser) {
$targetEndUser[$tgEndUser["id_Target_End_User"]] = $tgEndUser["Target_End_User"];
}
foreach ($lns as $langs) {
$languages[$langs["id_Language"]] = $langs["Language_Name"];
}
$companies = Companies::SelectOptionsModel();
$jobType = $jobs->getJobType();
$jobFamilyOptions = JobFamily::getJobsFamilyOptions();
$jobTypesOptions = JobType::getJobsTypesByJobFamilyOptions($jobType->id_Job_Family);
$countryModel = $address->getCountry();
$regionsOptions = Region::getRegionsOptions();
$countryOptions = Country::getCountriesOptionsByRegion($countryModel->id_Region);
return compact("companies", "commisionOrBonus", "targetEndUser", "jobFamilyOptions", "regionsOptions", "countryOptions", "languages", "jobs", "companyPreference", "address", "jobTypesOptions");
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit()
{
$User = Auth::user();
$this->data['User'] = $User;
$this->data['Countries'] = Country::orderBy('title')->get();
return view('client.users.edit', $this->data);
}
示例11: getAll
public static function getAll()
{
if (empty(self::$list)) {
if ($file = file_get_contents(Yii::$app->basePath . '/web/data/countries.json')) {
$list = Json::decode($file);
if (!empty($list['countries'])) {
foreach ($list['countries'] as $data) {
$country = new Country();
$country->load(['Country' => $data]);
self::$list[$data['code']] = $country;
}
}
}
}
return self::$list;
}
示例12: show
public function show($id)
{
$beatmapset = Beatmapset::with('beatmaps.failtimes', 'user')->findOrFail($id);
$set = json_item($beatmapset, new BeatmapsetTransformer(), ['beatmaps', 'beatmaps.failtimes', 'converts', 'converts.failtimes', 'user', 'description', 'ratings']);
$countries = json_collection(Country::all(), new CountryTransformer());
$title = trans('layout.menu.beatmaps._') . ' / ' . $beatmapset->artist . ' - ' . $beatmapset->title;
return view('beatmapsets.show', compact('set', 'title', 'countries'));
}
示例13: findModel
/**
* Finds the Country model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Country the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Country::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例14: actionIndex
public function actionIndex()
{
$country = new Country();
echo PRE;
$query = Country::find();
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
}
示例15: loadModel
/**
* Загружает запись модели текущего контроллера по айдишнику
* @param $id
* @return null|static
* @throws \yii\web\HttpException
*/
public function loadModel($id)
{
$model = Country::findOne($id);
if ($model === null) {
throw new \yii\web\HttpException(404, 'The requested page does not exist.');
}
return $model;
}