コード例 #1
0
 /**
  *
  * Handle the command
  *
  * @param RegisterEmployeeCommand $command
  * @return mixed
  */
 public function handle($command)
 {
     $account = Account::addAccount($command->username, $command->password);
     $employee = Employee::register($command->username, $command->first_name, $command->middle_name, $command->last_name, $command->birthdate, $command->address, $command->email, $command->mobile, $command->department_id);
     $this->accountRepository->save($account);
     $this->employeeRepository->save($employee);
     return $employee;
 }
コード例 #2
0
 /**
  * Update the password of the logged in user
  *
  * @param  String  $username
  * @return Redirect
  */
 public function update($username)
 {
     try {
         $this->changePasswordForm->validate(Input::all());
     } catch (FormValidationException $error) {
         return Redirect::back()->withInput()->withErrors($error->getErrors());
     }
     $user = Account::whereUsername($username)->firstOrFail();
     $old_password = Input::get('old_password');
     $new_password = Input::get('password');
     if (Hash::check($old_password, $user->getAuthPassword())) {
         $user->password = $new_password;
         if (!$user->save()) {
             Flash::error('Error: Failed saving new password!');
         }
         Flash::success('Password has been successfully changed!');
     } else {
         Flash::error('Old password given does not match record!');
     }
     return Redirect::route('accounts.edit', $username);
 }
コード例 #3
0
 /**
  * Soft delete employee account
  *
  * @param String $username
  * @return Account
  */
 public function remove($username)
 {
     $account = Account::withTrashed()->whereUsername($username)->firstOrFail();
     return $account->delete();
 }