/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     \DB::table('newsletter_subscriptors')->delete();
     $faker = \Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $subscriptor = \Modules\Newsletter\Entities\NewsletterSubscriptor::create(['name' => $faker->name, 'email' => $faker->email, 'verified' => $faker->randomElement([0, 1]), 'verification_key' => substr(sha1(rand()), 0, 32), 'active' => $faker->randomElement([0, 1])]);
     }
 }
 public function confirm($key)
 {
     $subscriptor = \Modules\Newsletter\Entities\NewsletterSubscriptor::where('verification_key', '=', $key)->first();
     if (!$subscriptor) {
         return view('fullPageMessage', array('title' => \Lang::get('newsletter::messages.errorConfirmingEmailTitle'), 'message' => \Lang::get('newsletter::messages.errorConfirmingEmailMessage'), 'buttons' => array(['label' => \Lang::get('newsletter::messages.homePage'), 'url' => '/'])));
     }
     $subscriptor->verified = true;
     $subscriptor->active = true;
     $subscriptor->save();
     $changeToLanguages = \Config::get('app.availableLanguagesFull');
     //unset($changeToLanguages[\App::getLocale()]);
     return view('newsletter::confirmed', array('title' => \Lang::get('newsletter::messages.successConfirmingEmailTitle'), 'message' => '<p>' . \Lang::get('newsletter::messages.successConfirmingEmailMessage') . '</p>', 'changeLangsMessage' => '<p>' . \Lang::get('newsletter::messages.changeNewsletterLanguageQuestion', ['lang' => \Config::get('app.availableLanguagesFull.' . \App::getLocale())]) . '</p>' . \Lang::get('newsletter::messages.changeNewsletterLanguageCallToAction'), 'changeToLanguages' => $changeToLanguages, 'selectedLanguage' => \Config::get('app.availableLanguagesFull.' . \App::getLocale()), 'buttons' => array(['label' => \Lang::get('newsletter::messages.homePage'), 'url' => '/']), 'csrfToken' => csrf_token(), 'email' => $subscriptor->email, 'verificationKey' => $key));
 }
 /**
  * @When I go to :lang validation url
  */
 public function iGoToValidationUrl($lang)
 {
     $subscriptor = \Modules\Newsletter\Entities\NewsletterSubscriptor::firstOrFail();
     $this->visit('/' . $lang . '/newsletter/confirm/' . $subscriptor->verification_key);
 }