public function doRegister(Request $request)
 {
     $validator = Validator::make($data = $request->all(), Admin::$rules, Admin::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if ($validator->passes()) {
         $confirmation_code = Str::quickRandom(30);
         $admin = new Admin();
         $admin->fullname = ucwords($request->fullname);
         $admin->mobile_no = $request->mobile_no;
         $admin->email = $request->email;
         $admin->password = bcrypt($request->password);
         $admin->confirmation_code = $confirmation_code;
         $data = ['confirmation_code' => $confirmation_code, 'username' => $request->username, 'password' => $request->password, 'mobile_no' => $request->mobile_no];
         Basehelper::sendSMS($request->mobile_no, 'Hello ' . $request->username . ', you have successfully registere. Your username is ' . $request->username . ' and password is ' . $request->password);
         // Mail::send('emails.verify', $data, function($message) use ($admin, $data){
         // 	$message->from('no-reply@employment_bank', 'Employment Bank');
         //     	$message->to(Input::get('email'), $admin->name)
         //         	->subject('Verify your email address');
         // });
         if (!$admin->save()) {
             return Redirect::back()->with('message', 'Error while creating your account!<br> Please contact Technical Support');
         }
         return Redirect::route('admin.login')->with('message', 'Account has been created!<br>Now Check your email address to verify your account by checking your spam folder or inboxes for verification link after that you can login');
         //sendConfirmation() Will go the email and sms as needed
     } else {
         return Redirect::back()->withInput()->withErrors($validation);
         // ->with('message', 'There were validation errors.');
     }
 }
Ejemplo n.º 2
0
 public function getVerificationStatusAttribute()
 {
     $user_name = '';
     if ($this->verified_by == 0) {
         return 'Not Verified';
     } else {
         try {
             $admin = Admin::findOrFail($this->verified_by);
             $user_name = $admin->fullname;
         } catch (ModelNotFoundException $e) {
             //dd(get_class_methods($e)) // lists all available methods for exception object
             //dd($e)
         }
         return 'Verified by ' . $user_name;
     }
 }