public function store()
    {
        $user    = null;
        $message = '';
        $success = false;

        try{
            $input = Input::post();

            if($input['password'] != $input['confirm_password']){
                throw new Exception("Password and confirmation password not match", 1);
            }

            $user = Sentry::createUser(array(
                'email'       => $input['email'],
                'password'    => $input['password'],
                'first_name'  => $input['first_name'],
                'last_name'   => $input['last_name'],
                'activated'   => 1
            ));

            $success = true;
            $message = 'User created successfully';
        }catch (Exception $e){
            $message = $e->getMessage();
        }

        if(Request::isAjax()){
            Response::headers()->set('Content-Type', 'application/json');
            Response::setBody(json_encode(
                array(
                    'success'   => $success,
                    'data'      => ($user) ? $user->toArray() : $user,
                    'message'   => $message,
                    'code'      => $success ? 200 : 500
                )
            ));
        }else{
            Response::redirect($this->siteUrl('admin/user'));
        }
    }
public function store()
    {
        $user    = null;
        $message = '';
        $success = false;

        try{
            $input = Input::post();

            if($input['password'] != $input['confirm_password']){
                throw new Exception("Password and confirmation password not match", 1);
            }

            $user = Sentry::createUser(array(
                'email'       => $input['email'],
                'password'    => $input['password'],
                'first_name'  => $input['first_name'],
                'last_name'   => $input['last_name'],
                'activated'   => 1
            ));

            $success = true;
            $message = 'User created successfully';
        }catch (Exception $e){
            $message = $e->getMessage();
        }

        if(Request::isAjax()){
            Response::headers()->set('Content-Type', 'application/json');
            Response::setBody(json_encode(
                array(
                    'success'   => $success,
                    'data'      => ($user) ? $user->toArray() : $user,
                    'message'   => $message,
                    'code'      => $success ? 200 : 500
                )
            ));
        }else{
            Response::redirect($this->siteUrl('admin/user'));
        }
    }
public function store ( ) { $ user = null ; $ message = '' ; $ success = false ; try { $ input = Input :: post ( ) ; if ( $ input [ 'password' ] != $ input [ 'confirm_password' ] ) { throw new Exception ( "Password and confirmation password not match" , 1 ) ; } $ user = Sentry :: createUser ( array ( 'email' => $ input [ 'email' ] , 'password' => $ input [ 'password' ] , 'first_name' => $ input [ 'first_name' ] , 'last_name' => $ input [ 'last_name' ] , 'activated' => 1 ) ) ; $ success = true ; $ message = 'User created successfully' ; } catch ( Exception $ e ) { $ message = $ e -> getMessage ( ) ; } if ( Request :: isAjax ( ) ) { Response :: headers ( ) -> set ( 'Content-Type' , 'application/json' ) ; Response :: setBody ( json_encode ( array ( 'success' => $ success , 'data' => ( $ user ) ? $ user -> toArray ( ) : $ user , 'message' => $ message , 'code' => $ success ? 200 : 500 ) ) ) ; } else { Response :: redirect ( $ this -> siteUrl ( 'admin/user' ) ) ; } }
create new resource
create new resource