Author: FuRongxin
Inheritance: extends Illuminate\Database\Eloquent\Model
Exemple #1
0
 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');
 }
 /**
  * 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]);
     }
 }
 /**
  * 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()));
 }
 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]);
 }
 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");
 }
 /**
  * @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('/')];
 }
 /**
  * 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']);
 }
 /**
  * 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();
     }
 }
 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");
 }
Exemple #10
0
 /**
  * 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);
 }
Exemple #11
0
 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;
 }
 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'));
 }
Exemple #13
0
 /**
  * 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.');
     }
 }
 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();
 }
Exemple #15
0
 /**
  * Загружает запись модели текущего контроллера по айдишнику
  * @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;
 }
 /**
  * Show the user's account.
  *
  * @return \Illuminate\View\View
  */
 public function showAccount(ApplicationRepository $applicationRepository)
 {
     $countries = array();
     foreach (Country::all() as $country) {
         $countries = array_add($countries, $country->id, $country->name);
     }
     return view('user.account')->with(['applications' => $applicationRepository->getAll(Auth::user()), 'countries' => $countries]);
 }
Exemple #17
0
 public function shippingDetails()
 {
     $userID = Session::get('loggedinUserId');
     $addresses = Address::where('user_id', '=', $userID)->get();
     $country = Country::all();
     $state = State::all();
     return view(Config('constants.frontendCheckoutView') . '.shipping', compact('country', 'state', 'addresses'));
 }
 /**
  * @return \Illuminate\View\View
  */
 public function showRegister()
 {
     $countries = array();
     foreach (Country::all() as $country) {
         $countries = array_add($countries, $country->id, $country->name);
     }
     return view('auth.register')->with(['countries' => $countries]);
 }
 public function addCountry(Country $country)
 {
     $countCountries = $this->getCountriesBy(Country::getTableName() . '.code', $country->code)->count();
     if ($countCountries == 0) {
         $this->getCountries()->attach($country->id);
     }
     $this->flushCacheByTags('CarriersCountries');
 }
 public function getCountries()
 {
     $ret = [];
     foreach (Country::find()->all() as $cc) {
         $ret[$cc->key] = $cc->id;
     }
     return $ret;
 }
 public function convertInputForOmnipay($input)
 {
     $data = ['firstName' => $input['first_name'], 'lastName' => $input['last_name'], 'number' => $input['card_number'], 'expiryMonth' => $input['expiration_month'], 'expiryYear' => $input['expiration_year'], 'cvv' => $input['cvv']];
     if (isset($input['country_id'])) {
         $country = Country::find($input['country_id']);
         $data = array_merge($data, ['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]);
     }
     return $data;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->command->info('Start country seeder!');
     $countries = $this->getCountryArray();
     foreach ($countries as $code => $name) {
         Country::create(['name' => $name, 'code' => $code]);
     }
     $this->command->info('Country table seeded!');
 }
 public function actionIndex()
 {
     $query = Country::find();
     //$query = Country::find()->andWhere(['code'=>'AU']);
     //初始化分页
     $pagination = new Pagination(['pageSize' => 2, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['countries' => $countries, 'pagination' => $pagination]);
 }
 public function actionCountry()
 {
     $countries = Country::find()->orderBy('name desc')->all();
     echo \yii\helpers\Json::encode($countries);
     $countryUs = Country::findOne('US');
     echo '<br />' . \yii\helpers\Json::encode($countryUs);
     $countryUs->name = 'U.S.A.';
     echo $countryUs->save() ? '  OK' : '  False';
 }
Exemple #25
0
 public function run()
 {
     DB::table('users')->delete();
     $VK = new VK(env('VK_APP_ID'), env('VK_KEY_SECRET'));
     $vkCountries = $VK->api('database.getCountries', ['need_all' => 1, 'count' => 1000, 'lang' => 'ru']);
     foreach ($vkCountries['response'] as $country) {
         Country::create(['id' => $country['cid'], 'title' => $country['title']]);
     }
 }
 public function run()
 {
     $this->command->info('Running UserTableSeeder');
     Eloquent::unguard();
     $faker = Faker\Factory::create();
     $company = Company::create();
     $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => min(InvoiceDesign::all()->random()->id, 10), 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]);
     User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false]);
     Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
 }
Exemple #27
0
 public function getState(Request $req)
 {
     $country = Country::find($req->id);
     $state = state::where('country_code', $country->code)->get();
     $html = '<option value="" selected>Choose Option</option>';
     foreach ($state as $states) {
         $html .= '<option value="' . $states->id . '">' . $states->name . '</option>';
     }
     echo $html;
 }
 public function getAttack($playerHash, $countryIdFrom, $countryIdTo)
 {
     $from = Country::find($countryIdFrom);
     /** @var $from Country */
     $to = Country::find($countryIdTo);
     $player = Player::getByHash($playerHash);
     if ($from->isOwnedBy($player)) {
         Action::attack($from, $to);
     }
 }
Exemple #29
0
 private static function createStartingCountries(Field $field)
 {
     $countries = new Collection();
     for ($x = 0; $x < \Config::get('settings.fieldWidth'); $x++) {
         for ($y = 0; $y < \Config::get('settings.fieldHeight'); $y++) {
             $countries->push(Country::create(['x' => $x, 'y' => $y, 'field_id' => $field->id]));
         }
     }
     return $countries;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('shipment_carriers_countries', function (Blueprint $table) {
         $table->bigInteger('carrier_id')->unsigned();
         $table->bigInteger('country_id')->unsigned();
         $table->foreign('carrier_id')->references('id')->on(Carrier::getTableName())->onDelete('cascade');
         $table->foreign('country_id')->references('id')->on(Country::getTableName())->onDelete('cascade');
         $table->primary(['carrier_id', 'country_id']);
     });
 }