public function claim()
 {
     Log::info('Inside Claim');
     Log::info(Input::all());
     $code = trim(Input::get('code'));
     $user_type = trim(Input::get('user_type'));
     $password = trim(Input::get('password'));
     $confirm_password = trim(Input::get('confirm_password'));
     $invite = Invite::where('code', '=', trim($code))->where('user_type', '=', $user_type)->where('claimed_at', '=', null)->first();
     if ($invite && $password == $confirm_password) {
         $user = User::find($invite->user_id);
         $user->password = $password;
         $user->confirmed = 1;
         $user->save();
         $this->respondWithArray(['success' => true, 'message' => 'Password Updated successfully. You can now login.']);
     } else {
         $this->respondWithArray(['success' => false, 'message' => 'Please make sure you clicked on the correct link and you put two identical password.']);
     }
 }
 /**
  * Create Agent
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     $success = false;
     if ($this->validator->validate(\Input::all()) && $this->userValidator->validate(['email' => \Input::get('email'), 'password' => \Str::random(8)])) {
         $user = User::create(['email' => \Input::get('email'), 'username' => \Input::get('name'), 'password' => \Str::random(8)]);
         $agentData = \Input::all();
         $agentData['user_id'] = $user->id;
         // TODO: save uploaded image :|
         // Destination path for uplaoded files which is at /public/uploads
         $destinationPath = public_path() . '/uploads/img/';
         // Handle profile Picture
         if (Input::hasFile('profile_pic_filename')) {
             $file = Input::file('profile_pic_filename');
             $propic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
             $uploadSuccess = $file->move($destinationPath, $propic_filename);
             if ($uploadSuccess) {
                 $agentData['profile_pic_filename'] = $propic_filename;
             }
         }
         $agent = Agent::create($agentData);
         // Send Invitation Email
         $invitation_code = bin2hex(openssl_random_pseudo_bytes(16));
         $invite = Invite::create(['code' => $invitation_code, 'email' => Input::get('email'), 'user_id' => $user->id, 'user_type' => 'Agent']);
         Mail::send('emails.invitation.invite', ['confirmation' => $invitation_code, 'client_base_url' => 'http://d.motibu-head.com/'], function ($message) {
             $message->to(Input::get('email'))->subject('You have been invited to motibu.com');
         });
         $user->roles()->attach(Role::findByName('Agent')->id);
         $success = $user && $agent;
     }
     return \Response::json(['success' => $success, 'data' => $agent->getTransformed(new AgentTransformer())]);
 }