public static function registerUser($input)
 {
     $User = new Admin_User();
     $id = $User->insert_get_id(array('username' => $input['username'], 'password' => Hash::make($input['password']), 'validationkey' => $input['key'], 'status' => 3, 'role' => $input['role']));
     unset($input['username']);
     unset($input['password']);
     unset($input['role']);
     unset($input['key']);
     if ($id) {
         // $extension = File::extension($input['imgpath']['name']);
         // $directory = path('public').'avatar/'.sha1($id);
         // $filename = sha1($id.time()).".{$extension}";
         // if($input['imgpath']['size'] != null){
         //     $upload_success = Input::upload('photo', $directory, $filename);
         //     if( $upload_success ) {
         //         $input['imgpath'] = 'avatar/'.sha1($id).'/'.$filename;
         //     }else{
         //         $input['imgpath'] = '';
         //     }
         // }else{
         //     $input['imgpath'] = '';
         // }
         $profile = new Admin_UserProfile(array('fullname' => $input['fullname'], 'icno' => $input['icno'], 'emel' => $input['emel']));
         $user = Admin_User::find($id);
         $user->userprofile()->insert($profile);
         return $profile->exists;
     } else {
         return false;
     }
 }
 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;
 }