You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-15Lines changed: 18 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -65,29 +65,32 @@ Tell your model to use the MongoDB model and set the collection (alias for table
65
65
66
66
}
67
67
68
-
*You can also specify the connection name in the model by changing the `connection` property.*
68
+
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:
69
+
70
+
use Jenssegers\Mongodb\Model as Eloquent;
71
+
72
+
class MyModel extends Eloquent {
73
+
74
+
protected $connection = 'mongodb';
75
+
76
+
}
69
77
70
78
Everything else works just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
71
79
72
-
Alternative Eloquent Setting
73
-
----------------------------
80
+
### Optional: Alias
81
+
-------------------
82
+
83
+
You may also register an alias for the MongoDB model by adding the following to the alias array in `app/config/app.php`:
84
+
85
+
'Moloquent' => 'Jenssegers\Mongodb\Model',
86
+
87
+
This will allow you to use your registered alias like:
74
88
75
-
'aliases' => array(...
76
-
'Moloquent' => 'Jenssegers\Mongodb\Model',
77
-
);
78
-
79
89
class MyModel extends Moloquent {
80
90
81
91
protected $collection = 'mycollection';
82
92
83
93
}
84
-
85
-
Add
86
-
87
-
protected $connection = 'mongodb';
88
-
89
-
in the MyModel if you have multiple database connections and do not want to overwrite the primary database connection.
0 commit comments