@@ -65,16 +65,26 @@ Tell your model to use the MongoDB model and set the collection (alias for table
...
@@ -65,16 +65,26 @@ Tell your model to use the MongoDB model and set the collection (alias for table
}
}
*You can also specify the connection name in the model by changing the `connection` property.*
If you are using a different database driver as the default one, you will need to specify the mongodb connection within your model by changing the `connection` property:
use Jenssegers\Mongodb\Model as Eloquent;
class MyModel extends Eloquent {
protected $connection = 'mongodb';
}
Everything else works just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
Everything else works just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
Alternative Eloquent Setting
### Optional: Alias
----------------------------
-------------------
You may also register an alias for the MongoDB model by adding the following to the alias array in `app/config/app.php`:
'aliases' => array(...
'Moloquent' => 'Jenssegers\Mongodb\Model',
'Moloquent' => 'Jenssegers\Mongodb\Model',
);
This will allow you to use your registered alias like:
class MyModel extends Moloquent {
class MyModel extends Moloquent {
...
@@ -82,13 +92,6 @@ Alternative Eloquent Setting
...
@@ -82,13 +92,6 @@ Alternative Eloquent Setting
}
}
Add
protected $connection = 'mongodb';
in the MyModel if you have multiple database connections and do not want to overwrite the primary database connection.