public function post_resetpassword()
 {
     $input = Input::all();
     $user = Admin_User::find(Auth::user()->userid);
     if (Hash::check($input['oldpassword'], $user->password) && $input['password'] == $input['repassword']) {
         $user->password = Hash::make($input['password']);
         $user->save();
     }
 }
 public static function confirmUser($input, $id = 0)
 {
     if ($id != 0) {
         $user = Admin_User::find($id);
         $user->username = $input['username'];
         $user->password = Hash::make($input['password']);
         $user->status = 2;
         $user->save();
         return true;
     } else {
         return false;
     }
 }
 public static function loggedprofile()
 {
     $logged_user = Auth::user();
     $userInfo = Admin_User::find($logged_user->userid)->userprofile;
     $data['profileid'] = $userInfo->profileid;
     // $data['userid'] = $userInfo->userid;
     $data['fullname'] = $userInfo->fullname;
     $data['icno'] = $userInfo->icno;
     $data['dob'] = $userInfo->dob;
     $data['emel'] = $userInfo->emel;
     $data['dob'] = $userInfo->dob;
     $data['address'] = $userInfo->address;
     $data['postcode'] = $userInfo->postcode;
     $data['town'] = $userInfo->town;
     $data['city'] = $userInfo->city;
     return json_encode($data);
 }
 public static function createAdmin()
 {
     $User = new Admin_User();
     $id = $User->insert_get_id(array('username' => 'administrator', 'password' => Hash::make('password'), 'validationkey' => Str::random(32, 'alpha'), 'status' => 2, 'role' => 1));
     $profile = new Admin_UserProfile(array('fullname' => 'System Administrator'));
     $user = Admin_User::find($id);
     $user->userprofile()->insert($profile);
     return $id;
 }