for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Modules\User\Commands\Handlers;
use Illuminate\Support\Facades\Event;
use Modules\Core\Contracts\Authentication;
use Modules\User\Events\UserHasBegunResetProcess;
use Modules\User\Exceptions\UserNotFoundException;
use Modules\User\Repositories\UserRepository;
class BeginResetProcessCommandHandler
{
/**
* @var UserRepository
*/
private $user;
* @var Authentication
private $auth;
public function __construct(UserRepository $user, Authentication $auth)
$this->user = $user;
$this->auth = $auth;
}
* Handle the command
*
* @param $command
* @throws UserNotFoundException
* @return mixed
public function handle($command)
$user = $this->findUser((array) $command);
$code = $this->auth->createReminderCode($user);
event(new UserHasBegunResetProcess($user, $code));
private function findUser($credentials)
$user = $this->user->findByCredentials((array) $credentials);
if ($user) {
return $user;
throw new UserNotFoundException();