/** * * 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; }
/** * Command handler * * @param RemoveEmployeeCommand * @return Employee */ public function handle($command) { $accountDelete = $this->accountRepository->remove($command->username); $employeeDelete = $this->employeeRepository->remove($command->username); return $employeeDelete; }