Unable to implement mongor bundle in laravel

85 views Asked by At

I am trying to implement mongor bundle for laravel version 3.2.14

I have followed all the steps as mentioned in the documentation on mongor homepage

There is no documentation regarding its usage in the homepage but by chance i got the following link : bundle full example

In-spite of following this i am unable to understand why my code is not working.

Strangely i am not getting any errors.

My code is as follows

database.php

'mongor' => array(
        'hostname'   => '127.0.0.1',
        'connect'    => true,
        'timeout'    => '',
        'replicaSet' => '',
        'db'         => 'census',
        'username'   => 'root',
        'password'   => '',
        ),

user.php(Model)

class User extends Mongor\Model{

    public static $timestamps = true;

    public function __construct($connection = NULL)
    {
        parent::__construct($connection);
        static::$collection = 'user';
    }


}

user.php(Controller)

public function get_index()
    {           
        //return View::make('user.index');
        $users = User::first();
        dd($users);

    }

I am getting following data when i execute this url:

object(User)#28 (14) {
  ["connection"]=>
  object(Mongor\MongoDB)#29 (4) {
    ["_name":protected]=>
    NULL
    ["_connected":protected]=>
    bool(true)
    ["_connection":protected]=>
    object(Mongo)#30 (4) {
      ["connected"]=>
      bool(true)
      ["status"]=>
      NULL
      ["server":protected]=>
      string(19) "mongodb://localhost"
      ["persistent":protected]=>
      NULL
    }
    ["_db":protected]=>
    object(MongoDB)#31 (2) {
      ["w"]=>
      int(1)
      ["wtimeout"]=>
      int(10000)
    }
  }
  ["exists"]=>
  bool(false)
  ["attributes"]=>
  NULL
  ["dirty"]=>
  array(0) {
  }
  ["ignore"]=>
  array(0) {
  }
  ["includes"]=>
  array(0) {
  }
  ["relating"]=>
  NULL
  ["relating_key"]=>
  NULL
  ["relating_table"]=>
  NULL
  ["_limit"]=>
  NULL
  ["_skip"]=>
  NULL
  ["_where"]=>
  array(0) {
  }
  ["_sort"]=>
  array(0) {
  }
  ["_count":protected]=>
  NULL
}

Whereas when i execute the command db.user.find() in the mongo shell i get all the relevant results.

0

There are 0 answers