/**
  * Handle the command.
  *
  * @param object $command
  * @return void
  */
 public function handle($command)
 {
     $activation_code = Shorten::generateHash(40);
     $user = $this->model->register($command->username, $command->email, $command->password, $activation_code);
     $this->repository->save($user);
     $this->dispatchEventsFor($user);
     return $user;
 }
 /**
  * Handle the command.
  * @param object $command
  * @return void
  */
 public function handle($command)
 {
     if ($hash = Shorten::exists($command->url)) {
         return $hash;
     }
     $hash = Shorten::generateHash();
     $user_id = \Auth::user() ? \Auth::user()->id : 0;
     $link = $this->model->generate($user_id, $command->url, $hash);
     $this->dispatchEventsFor($link);
     $this->repository->save($link);
     return $hash;
 }
예제 #3
0
 /**
  * Get the hash and redirect to specified url
  * GET /{hash}
  * @param  int  $hash
  * @return Response
  */
 public function show($hash)
 {
     $url = Shorten::getUrlByHash($hash);
     return Redirect::to($url);
 }