/** * Saving new password. * * @param \Orchestra\Model\User $user * @param array $input */ protected function saving(Eloquent $user, array $input) { $user->setAttribute('password', $input['new_password']); DB::transaction(function () use($user) { $user->save(); }); }
/** * Handle `orchestra.saved: user.account` event. * * @param \Orchestra\Model\User $user * * @return void */ public function handle($user) { if (!$this->isLocaltimeEnabled()) { return; } $userId = $user->getAttribute('id'); $meta = $this->memory->make('user'); $meta->put("timezone.{$userId}", Input::get('meta_timezone')); }
/** * Save user profile. * * @param \Orchestra\Model\User|\Illuminate\Database\Eloquent\Model $user * @param array $input * * @return void */ protected function saving($user, array $input) { $user->setAttribute('email', $input['email']); $user->setAttribute('fullname', $input['fullname']); $this->fireEvent('updating', [$user]); $this->fireEvent('saving', [$user]); $user->saveOrFail(); $this->fireEvent('updated', [$user]); $this->fireEvent('saved', [$user]); }
/** * Save the user. * * @param \Orchestra\Model\User $user * @param array $input * @param string $type * * @return bool */ protected function saving(Eloquent $user, $input = [], $type = 'create') { $beforeEvent = $type === 'create' ? 'creating' : 'updating'; $afterEvent = $type === 'create' ? 'created' : 'updated'; $user->fullname = $input['fullname']; $user->email = $input['email']; $this->fireEvent($beforeEvent, [$user]); $this->fireEvent('saving', [$user]); DB::transaction(function () use($user, $input) { $user->save(); $user->roles()->sync($input['roles']); }); $this->fireEvent($afterEvent, [$user]); $this->fireEvent('saved', [$user]); return true; }
/** * Validate current user. * * @param \Orchestra\Model\User|\Illuminate\Database\Eloquent\Model $user * @param array $input * * @return bool */ protected function validateCurrentUser($user, array $input) { return (string) $user->getAttribute('id') === $input['id']; }
/** * Verify user account if has not been verified, other this should * be ignored in most cases. * * @param \Orchestra\Model\User $user * * @return \Orchestra\Model\User */ protected function verifyWhenFirstTimeLogin(Eloquent $user) { if ((int) $user->getAttribute('status') === Eloquent::UNVERIFIED) { $user->activate()->save(); } return $user; }
/** * Saving new user. * * @param \Orchestra\Model\User $user * @param array $input * @param string $password * * @return void */ protected function saving(Eloquent $user, array $input, $password) { $user->setAttribute('email', $input['email']); $user->setAttribute('fullname', $input['fullname']); $user->setAttribute('password', $password); $this->fireEvent('creating', [$user]); $this->fireEvent('saving', [$user]); DB::transaction(function () use($user) { $user->save(); $user->roles()->sync([Config::get('orchestra/foundation::roles.member', 2)]); }); $this->fireEvent('created', [$user]); $this->fireEvent('saved', [$user]); }
/** * Saving new password. * * @param \Orchestra\Model\User $user * @param array $input */ protected function saving(Eloquent $user, array $input) { $user->setAttribute('password', $input['new_password']); $user->saveOrFail(); }