This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{}
classUserextendsEloquent{}
```
```
...
@@ -115,7 +115,7 @@ class User extends Eloquent {}
...
@@ -115,7 +115,7 @@ class User extends Eloquent {}
Note that we did not tell Eloquent which collection to use for the `User` model. Just like the original Eloquent, the lower-case, plural name of the class will be used as the table name unless another name is explicitly specified. You may specify a custom collection (alias for table) by defining a `collection` property on your model:
Note that we did not tell Eloquent which collection to use for the `User` model. Just like the original Eloquent, the lower-case, plural name of the class will be used as the table name unless another name is explicitly specified. You may specify a custom collection (alias for table) by defining a `collection` property on your model:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
classUserextendsEloquent{
...
@@ -127,7 +127,7 @@ class User extends Eloquent {
...
@@ -127,7 +127,7 @@ class User extends Eloquent {
**NOTE:** Eloquent will also assume that each collection has a primary key column named id. You may define a `primaryKey` property to override this convention. Likewise, you may define a `connection` property to override the name of the database connection that should be used when utilizing the model.
**NOTE:** Eloquent will also assume that each collection has a primary key column named id. You may define a `primaryKey` property to override this convention. Likewise, you may define a `connection` property to override the name of the database connection that should be used when utilizing the model.
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classMyModelextendsEloquent{
classMyModelextendsEloquent{
...
@@ -143,7 +143,7 @@ Everything else works just like the original Eloquent model. Read more about the
...
@@ -143,7 +143,7 @@ Everything else works just like the original Eloquent model. Read more about the
You may also register an alias for the MongoDB model by adding the following to the alias array in `app/config/app.php`:
You may also register an alias for the MongoDB model by adding the following to the alias array in `app/config/app.php`:
```php
```php
'Moloquent'=>'Jenssegers\Mongodb\Model',
'Moloquent'=>'Jenssegers\Mongodb\Eloquent\Model',
```
```
This will allow you to use the registered alias like:
This will allow you to use the registered alias like:
...
@@ -233,10 +233,10 @@ MongoDB Support => enabled
...
@@ -233,10 +233,10 @@ MongoDB Support => enabled
#### Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given
#### Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given
To solve this, you will need to check two things. First check if your model is extending the correct class; this class should be `Jenssegers\Mongodb\Model`. Secondly, check if your model is using a MongoDB connection. If you did not change the default database connection in your database configuration file, you need to specify the MongoDB enabled connection. This is what your class should look like if you did not set up an alias and change the default database connection:
To solve this, you will need to check two things. First check if your model is extending the correct class; this class should be `Jenssegers\Mongodb\Eloquent\Model`. Secondly, check if your model is using a MongoDB connection. If you did not change the default database connection in your database configuration file, you need to specify the MongoDB enabled connection. This is what your class should look like if you did not set up an alias and change the default database connection:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
classUserextendsEloquent{
...
@@ -531,7 +531,7 @@ Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate ob
...
@@ -531,7 +531,7 @@ Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate ob
Example:
Example:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
classUserextendsEloquent{
...
@@ -558,7 +558,7 @@ Supported relations are:
...
@@ -558,7 +558,7 @@ Supported relations are:
Example:
Example:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
classUserextendsEloquent{
...
@@ -573,7 +573,7 @@ class User extends Eloquent {
...
@@ -573,7 +573,7 @@ class User extends Eloquent {
And the inverse relation:
And the inverse relation:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classItemextendsEloquent{
classItemextendsEloquent{
...
@@ -588,7 +588,7 @@ class Item extends Eloquent {
...
@@ -588,7 +588,7 @@ class Item extends Eloquent {
The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless. If you want to define custom keys for your relation, set it to `null`:
The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless. If you want to define custom keys for your relation, set it to `null`:
```php
```php
useJenssegers\Mongodb\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
classUserextendsEloquent{
...
@@ -608,7 +608,7 @@ Other relations are not yet supported, but may be added in the future. Read more
...
@@ -608,7 +608,7 @@ Other relations are not yet supported, but may be added in the future. Read more
If you want to embed models, rather than referencing them, you can use the `embedsMany` relation. This relation is similar to the `hasMany` relation, but embeds the models inside the parent object.
If you want to embed models, rather than referencing them, you can use the `embedsMany` relation. This relation is similar to the `hasMany` relation, but embeds the models inside the parent object.