예제 #1
0
 protected function profileInfo()
 {
     foreach (User::all() as $user) {
         $user->fill(['nl' => ['bio' => $this->nl->paragraph(6, true), 'quote' => $this->nl->sentence(8, true), 'quote_author' => $this->nl->name], 'fr' => ['bio' => $this->nl->paragraph(6, true), 'quote' => $this->nl->sentence(8, true), 'quote_author' => $this->nl->name], 'en' => ['bio' => $this->nl->paragraph(6, true), 'quote' => $this->nl->sentence(8, true), 'quote_author' => $this->nl->name], 'de' => ['bio' => $this->nl->paragraph(6, true), 'quote' => $this->nl->sentence(8, true), 'quote_author' => $this->nl->name]]);
         $user->save();
     }
 }
예제 #2
0
 public function run($creating = 15)
 {
     foreach ([1, 2] as $accountid) {
         $account = Account::find($accountid);
         $clients = Client::all();
         $users = User::all();
         $users = $users->lists('id')->toArray();
         //flip so we can use array_rand
         $tags = array_flip(Tag::lists('id')->toArray());
         for ($i = 0; $i < $creating; $i++) {
             $project = Modules\Portfolio\Project::create(['account_id' => $account->id, 'date' => $this->nl->dateTimeBetween('-3 months', 'now'), 'website' => $this->nl->url, 'nl' => ['published' => rand(0, 1), 'title' => $this->nl->sentence(2), 'content' => $this->nl->text(1300), 'created_at' => $this->nl->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->nl->dateTimeBetween('-2 months', 'now')], 'fr' => ['published' => rand(0, 1), 'title' => $this->fr->sentence(2), 'content' => $this->fr->text(1300), 'created_at' => $this->fr->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->fr->dateTimeBetween('-2 months', 'now')], 'en' => ['published' => rand(0, 1), 'title' => $this->en->sentence(2), 'content' => $this->en->text(1300), 'created_at' => $this->en->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->en->dateTimeBetween('-2 months', 'now')], 'de' => ['published' => rand(0, 1), 'title' => $this->de->sentence(2), 'content' => $this->de->text(1300), 'created_at' => $this->de->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->de->dateTimeBetween('-2 months', 'now')]]);
             $this->addImages($project);
             //foreach project we randomly add 1 to 3 collaborators
             $amount = rand(1, 3);
             $possibleUsers = $users;
             for ($j = 0; $j < $amount; $j++) {
                 shuffle($possibleUsers);
                 $add = array_shift($possibleUsers);
                 $project->collaborators()->attach($add);
             }
             $project->tags()->sync(array_rand($tags, 2));
             $project->client()->associate($clients->random());
             $project->save();
         }
     }
 }
예제 #3
0
 /**
  * @param Gravatar $gravatar
  * @param Filesystem $files
  * @param AccountManager $manager
  * @throws \Exception
  */
 public function handle(Gravatar $gravatar, Filesystem $files, AccountManager $manager)
 {
     if ($gravatar->exists($this->user->email)) {
         $gravatar->setAvatarSize(512);
         $url = $gravatar->get($this->user->email);
         $content = file_get_contents($url);
         $tmpDir = storage_path('media' . '/' . $this->user->getMediaFolder());
         if (!$files->isDirectory($tmpDir)) {
             $files->makeDirectory($tmpDir, 0755, true);
         }
         $path = $tmpDir . sha1(time() . 'user-profile-pic' . $this->user->id);
         $files->put($path, $content);
         $finalPath = $this->pathWithExtension($path);
         $files->move($path, $finalPath);
         $this->dispatch(new StoreNewImage($manager->account(), $this->user, $finalPath));
         $files->delete($finalPath);
     }
 }
예제 #4
0
 /**
  * @param User $user
  * @param Hasher $hash
  * @param Dispatcher $events
  * @return User
  * @throws Exception
  */
 public function handle(User $user, Hasher $hash, Dispatcher $events)
 {
     $connection = $user->getConnection();
     $connection->beginTransaction();
     //we already have a user with this email.
     try {
         if (!$this->user) {
             $this->user = $user;
             $this->user->email = $this->email;
             $this->user->password = $hash->make($this->password);
             $this->user->save();
         }
         $events->fire(new UserRegistered($this->user, $this->invitation));
         $connection->commit();
         return $this->user;
     } catch (Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
예제 #5
0
 public function run()
 {
     foreach ([1, 2] as $account) {
         foreach (User::all() as $user) {
             $membership = new Membership();
             $membership->user_id = $user->id;
             $membership->account_id = $account;
             $membership->role_id = 1;
             $membership->is_owner = $user->id == 1 ? 1 : 0;
             $membership->save();
         }
     }
 }
 /**
  * @param MembershipRepository $repository
  * @param $invitation
  * @param Guard $guard
  * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
  */
 public function show(MembershipRepository $repository, $invitation, Guard $guard)
 {
     $invitation = $repository->findInvitationByToken($invitation);
     if (!$invitation) {
         return redirect()->to(store_route('store.home'));
     }
     //do we have an invitation for a user with a registered account?
     //if so, we simply accept it instead of asking for credentials.
     if ($user = User::where('email', $invitation->email)->limit(1)->first()) {
         $user = $this->dispatch(new Signup(false, false, $invitation));
         if ($user->confirmed) {
             //user can be logged in too
             $guard->login($user);
             return redirect()->to(store_route('store.dash'));
         }
         return redirect()->to(store_route('store.home'))->with('message', 'success');
     }
     return $this->theme->render('auth.register', ['invitation' => $invitation]);
 }
예제 #7
0
 public function run()
 {
     User::create(['email' => '*****@*****.**', 'password' => \Hash::make('thomasthomas'), 'firstname' => 'Thomas', 'lastname' => 'Warlop', 'confirmed' => 1]);
 }
예제 #8
0
 /**
  * @param $email
  * @return \Illuminate\Database\Eloquent\Model|null|static
  */
 public function findUserByEmail($email)
 {
     return $this->user->newQuery()->where('email', $email)->first();
 }