An Eloquent model and Query builder with support for MongoDB, using the original Laravel API. *This library extends the original Laravel classes, so it uses exactly the same methods.*
This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. *This library extends the original Laravel classes, so it uses exactly the same methods.*
Table of contents
-[Laravel MongoDB](#laravel-mongodb)
-----------------
-[Installation](#installation)
*[Installation](#installation)
-[Laravel version Compatibility](#laravel-version-compatibility)
*[Upgrading](#upgrading)
-[Laravel](#laravel)
*[Configuration](#configuration)
-[Lumen](#lumen)
*[Eloquent](#eloquent)
-[Non-Laravel projects](#non-laravel-projects)
*[Optional: Alias](#optional-alias)
-[Testing](#testing)
*[Query Builder](#query-builder)
-[Configuration](#configuration)
*[Schema](#schema)
-[Eloquent](#eloquent)
*[Extensions](#extensions)
-[Extending the base model](#extending-the-base-model)
In case your Laravel version does NOT autoload the packages, add the service provider to `config/app.php`:
```php
```php
Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\MongodbServiceProvider::class,
```
```
### Lumen
For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. In this file, you will also need to enable Eloquent. You must however ensure that your call to `$app->withEloquent();` is **below** where you have registered the `MongodbServiceProvider`:
For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. In this file, you will also need to enable Eloquent. You must however ensure that your call to `$app->withEloquent();` is **below** where you have registered the `MongodbServiceProvider`:
The service provider will register a mongodb database extension with the original database manager. There is no need to register additional facades or objects. When using mongodb connections, Laravel will automatically provide you with the corresponding mongodb objects.
The service provider will register a MongoDB database extension with the original database manager. There is no need to register additional facades or objects.
When using MongoDB connections, Laravel will automatically provide you with the corresponding MongoDB objects.
### Non-Laravel projects
For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
In this new major release which supports the new mongodb PHP extension, we also moved the location of the Model class and replaced the MySQL model class with a trait.
Please change all `Jenssegers\Mongodb\Model` references to `Jenssegers\Mongodb\Eloquent\Model` either at the top of your model files, or your registered alias.
```php
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{}
```
If you are using hybrid relations, your MySQL classes should now extend the original Eloquent model class `Illuminate\Database\Eloquent\Model` instead of the removed `Jenssegers\Eloquent\Model`. Instead use the new `Jenssegers\Mongodb\Eloquent\HybridRelations` trait. This should make things more clear as there is only one single model class in this package.
```php
useJenssegers\Mongodb\Eloquent\HybridRelations;
classUserextendsEloquent{
useHybridRelations;
protected$connection='mysql';
}
```
Embedded relations now return an `Illuminate\Database\Eloquent\Collection` rather than a custom Collection class. If you were using one of the special methods that were available, convert them to Collection operations.
```php
$books=$user->books()->sortBy('title');
```
Testing
Testing
-------
-------
...
@@ -123,301 +115,238 @@ docker-compose up
...
@@ -123,301 +115,238 @@ docker-compose up
Configuration
Configuration
-------------
-------------
You can use MongoDB either as the main database, either as a side database. To do so, add a new `mongodb` connection to `config/database.php`:
Change your default database connection name in `config/database.php`:
```php
'default'=>env('DB_CONNECTION','mongodb'),
```
And add a new mongodb connection:
```php
```php
'mongodb'=>[
'mongodb'=>[
'driver'=>'mongodb',
'driver'=>'mongodb',
'host'=>env('DB_HOST','localhost'),
'host'=>env('DB_HOST','127.0.0.1'),
'port'=>env('DB_PORT',27017),
'port'=>env('DB_PORT',27017),
'database'=>env('DB_DATABASE'),
'database'=>env('DB_DATABASE','homestead'),
'username'=>env('DB_USERNAME'),
'username'=>env('DB_USERNAME','homestead'),
'password'=>env('DB_PASSWORD'),
'password'=>env('DB_PASSWORD','secret'),
'options'=>[
'options'=>[
'database'=>'admin'// sets the authentication database required by mongo 3
// here you can pass more settings to the Mongo Driver Manager
]
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'database'=>env('DB_AUTHENTICATION_DATABASE','admin'),// required with Mongo 3+
],
],
],
```
```
You can connect to multiple servers or replica sets with the following configuration:
For multiple servers or replica set configurations, set the host to an array and specify each server host:
```php
```php
'mongodb'=>[
'mongodb'=>[
'driver'=>'mongodb',
'driver'=>'mongodb',
'host'=>['server1','server2'],
'host'=>['server1','server2',...],
'port'=>env('DB_PORT',27017),
...
'database'=>env('DB_DATABASE'),
'options'=>[
'username'=>env('DB_USERNAME'),
'replicaSet'=>'rs0',
'password'=>env('DB_PASSWORD'),
],
'options'=>[
'replicaSet'=>'replicaSetName'
]
],
],
```
```
Alternatively, you can use MongoDB connection string:
If you wish to use a connection string instead of full key-value params, you can set it so. Check the documentation on MongoDB's URI format: https://docs.mongodb.com/manual/reference/connection-string/
```php
```php
'mongodb'=>[
'mongodb'=>[
'driver'=>'mongodb',
'driver'=>'mongodb',
'dsn'=>env('DB_DSN'),
'dsn'=>env('DB_DSN'),
'database'=>env('DB_DATABASE'),
'database'=>env('DB_DATABASE','homestead'),
],
],
```
```
Please refer to MongoDB official docs for its URI format: https://docs.mongodb.com/manual/reference/connection-string/
Eloquent
Eloquent
--------
--------
### Extending the base model
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\Eloquent\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\Model;
classUserextendsEloquent{}
```
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 collection 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
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
protected$collection='users_collection';
classBookextendsModel
{
//
}
}
```
```
**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.
Just like a normal model, the MongoDB model class will know which collection to use based on the model name. For `Book`, the collection `books` will be used.
```php
To change the collection, pass the `$collection` property:
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classMyModelextendsEloquent{
protected$connection='mongodb';
```php
useJenssegers\Mongodb\Eloquent\Model;
classBookextendsModel
{
protected$collection='my_books_collection';
}
}
```
```
Everything else (should) work just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
**NOTE:** MongoDB documents are automatically stored with a unique ID that is stored in the `_id` property. If you wish to use your own ID, substitute the `$primaryKey` property and set it to your own primary key attribute name.
### Optional: Alias
You may also register an alias for the MongoDB model by adding the following to the alias array in `config/app.php`:
This will allow you to use the registered alias like:
classBookextendsModel
{
protected$primaryKey='id';
}
```php
// Mongo will also create _id, but the 'id' property will be used for primary key actions like find().
classMyModelextendsMoloquent{}
Book::create(['id'=>1,'title'=>'The Fault in Our Stars']);
```
```
Query Builder
Likewise, you may define a `connection` property to override the name of the database connection that should be used when utilizing the model.
-------------
The database driver plugs right into the original query builder. When using mongodb connections, you will be able to build fluent queries to perform database operations. For your convenience, there is a `collection` alias for `table` as well as some additional mongodb specific operators/operations.
Read more about the query builder on http://laravel.com/docs/queries
### Soft Deletes
Schema
When soft deleting a model, it is not actually removed from your database. Instead, a deleted_at timestamp is set on the record.
------
The database driver also has (limited) schema builder support. You can easily manipulate collections and set indexes:
To enable soft deletes for a model, apply the `Jenssegers\Mongodb\Eloquent\SoftDeletes` Trait to the model:
```php
```php
Schema::create('users',function($collection)
useJenssegers\Mongodb\Eloquent\SoftDeletes;
{
$collection->index('name');
$collection->unique('email');
});
```
You can also pass all the parameters specified in the MongoDB docs [here](https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options-for-all-index-types) in the `$options` parameter. For example:
```
classUserextendsModel
Schema::create('users', function($collection)
{
{
$collection->index('username',null,null,[
useSoftDeletes;
'sparse' => true,
'unique' => true,
'background' => true
]);
});
```
Supported operations are:
- create and drop
- collection
- hasCollection
- index and dropIndex (compound indexes supported as well)
All other (unsupported) operations are implemented as dummy pass-through methods, because MongoDB does not use a predefined schema. Read more about the schema builder on https://laravel.com/docs/6.0/migrations#tables
protected$dates=['deleted_at'];
}
```
### Geospatial indexes
For more information check [Laravel Docs about Soft Deleting](http://laravel.com/docs/eloquent#soft-deleting).
Geospatial indexes are handy for querying location-based documents. They come in two forms: `2d` and `2dsphere`. Use the schema builder to add these to a collection.
### Dates
To add a `2d` index:
Eloquent allows you to work with Carbon or DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database.
```php
```php
Schema::create('users',function($collection)
useJenssegers\Mongodb\Eloquent\Model;
{
$collection->geospatial('name','2d');
});
```
To add a `2dsphere` index:
classUserextendsModel
```php
Schema::create('users',function($collection)
{
{
$collection->geospatial('name','2dsphere');
protected$dates=['birthday'];
});
}
```
```
Extensions
This allows you to execute queries like this:
----------
### Auth
If you want to use Laravel's native Auth functionality, register this included service provider:
This service provider will slightly modify the internal DatabaseReminderRepository to add support for MongoDB based password reminders. If you don't use password reminders, you don't have to register this service provider and everything else should work just fine.
### Basic Usage
### Queues
If you want to use MongoDB as your database backend, change the driver in `config/queue.php`:
**Retrieving all models**
```php
```php
'connections'=>[
$users=User::all();
'database'=>[
'driver'=>'mongodb',
'table'=>'jobs',
'queue'=>'default',
'expire'=>60,
],
]
```
```
If you want to use MongoDB to handle failed jobs, change the database in `config/queue.php`:
If you want to use this library with [Sentry](https://cartalyst.com/manual/sentry), then check out https://github.com/jenssegers/Laravel-MongoDB-Sentry
### Sessions
The MongoDB session driver is available in a separate package, check out https://github.com/jenssegers/Laravel-MongoDB-Session
When soft deleting a model, it is not actually removed from your database. Instead, a deleted_at timestamp is set on the record. To enable soft deletes for a model, apply the SoftDeletingTrait to the model:
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a MongoDB\BSON\Regex object.
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a `MongoDB\BSON\Regex` object.
Inserting, updating and deleting records works just like the original Eloquent. Please check [Laravel Docs' Eloquent section](https://laravel.com/docs/6.x/eloquent).
**Where**
Here, only the MongoDB-specific operations are specified.
Matches documents that satisfy a JavaScript expression. For more information check http://docs.mongodb.org/manual/reference/operator/query/where/#op._S_where
### Inserts, updates and deletes
### MongoDB specific operations
Inserting, updating and deleting records works just like the original Eloquent.
**Raw Expressions**
**Saving a new model**
These expressions will be injected directly into the query.
```php
```php
$user=newUser;
User::whereRaw([
$user->name='John';
'age'=>['$gt'=>30,'$lt'=>40],
$user->save();
])->get();
```
```
You may also use the create method to save a new model in a single line:
You can also perform raw expressions on the internal MongoCollection object. If this is executed on the model class, it will return a collection of models.
If this is executed on the query builder, it will return the original response.
**Cursor timeout**
To prevent `MongoCursorTimeout` exceptions, you can manually set a timeout value that will be applied to the cursor:
```php
```php
User::create(['name'=>'John']);
DB::collection('users')->timeout(-1)->get();
```
```
**Updating a model**
**Upsert**
To update a model, you may retrieve it, change an attribute, and use the save method.
Update or insert a document. Additional options for the update method are passed directly to the native update method.
```php
```php
$user=User::first();
// Query Builder
$user->email='john@foo.com';
DB::collection('users')
$user->save();
->where('name','John')
->update($data,['upsert'=>true]);
// Eloquent
$user->update($data,['upsert'=>true]);
```
```
*There is also support for upsert operations, check https://github.com/jenssegers/laravel-mongodb#mongodb-specific-operations*
**Projections**
You can apply projections to your queries using the `project` method.
```php
DB::collection('items')
->project(['tags'=>['$slice'=>1]])
->get();
**Deleting a model**
DB::collection('items')
->project(['tags'=>['$slice'=>[3,7]]])
->get();
```
To delete a model, simply call the delete method on the instance:
**Projections with Pagination**
```php
```php
$user=User::first();
$limit=25;
$user->delete();
$projections=['id','name'];
DB::collection('items')
->paginate($limit,$projections);
```
```
Or deleting a model by its key:
**Push**
Add items to an array.
```php
```php
User::destroy('517c43667db388101e00000f');
DB::collection('users')
->where('name','John')
->push('items','boots');
$user->push('items','boots');
```
```
For more information about model manipulation, check http://laravel.com/docs/eloquent#insert-update-delete
```php
DB::collection('users')
->where('name','John')
->push('messages',[
'from'=>'Jane Doe',
'message'=>'Hi John',
]);
### Dates
$user->push('messages',[
'from'=>'Jane Doe',
'message'=>'Hi John',
]);
```
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: https://laravel.com/docs/5.0/eloquent#date-mutators
If you **DON'T** want duplicate items, set the third parameter to `true`:
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`:
### belongsToMany and pivots
```php
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.
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
classUserextendsEloquent{
If you want to define custom keys for your relation, set it to `null`:
Other relations are not yet supported, but may be added in the future. Read more about these relations on https://laravel.com/docs/master/eloquent-relationships
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.
### EmbedsMany Relations
**REMEMBER**: These relations return Eloquent collections, they don't return query builder objects!
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.
**REMEMBER**: these relations return Eloquent collections, they don't return query builder objects!
```php
```php
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\Model;
classUserextendsEloquent{
classUserextendsModel
{
publicfunctionbooks()
publicfunctionbooks()
{
{
return$this->embedsMany('Book');
return$this->embedsMany(Book::class);
}
}
}
}
```
```
You can access the embedded models through the dynamic property:
You can access the embedded models through the dynamic property:
```php
```php
$books=User::first()->books;
$user=User::first();
foreach($user->booksas$book){
//
}
```
```
The inverse relation is auto*magically* available, you don't need to define this reverse relation.
The inverse relation is auto*magically* available. You don't need to define this reverse relation.
```php
```php
$book=Book::first();
$user=$book->user;
$user=$book->user;
```
```
Inserting and updating embedded models works similar to the `hasMany` relation:
Inserting and updating embedded models works similar to the `hasMany` relation:
```php
```php
$book=newBook(['title'=>'A Game of Thrones']);
$book=$user->books()->save(
newBook(['title'=>'A Game of Thrones'])
);
$user=User::first();
$book=$user->books()->save($book);
// or
// or
$book=$user->books()->create(['title'=>'A Game of Thrones'])
$book=
$user->books()
->create(['title'=>'A Game of Thrones']);
```
```
You can update embedded models using their `save` method (available since release 2.0.0):
You can update embedded models using their `save` method (available since release 2.0.0):
...
@@ -837,69 +799,78 @@ You can update embedded models using their `save` method (available since releas
...
@@ -837,69 +799,78 @@ You can update embedded models using their `save` method (available since releas
$book=$user->books()->first();
$book=$user->books()->first();
$book->title='A Game of Thrones';
$book->title='A Game of Thrones';
$book->save();
$book->save();
```
```
You can remove an embedded model by using the `destroy` method on the relation, or the `delete` method on the model (available since release 2.0.0):
You can remove an embedded model by using the `destroy` method on the relation, or the `delete` method on the model (available since release 2.0.0):
```php
```php
$book=$user->books()->first();
$book->delete();
$book->delete();
// or
// Similar operation
$user->books()->destroy($book);
$user->books()->destroy($book);
```
```
If you want to add or remove an embedded model, without touching the database, you can use the `associate` and `dissociate` methods. To eventually write the changes to the database, save the parent object:
If you want to add or remove an embedded model, without touching the database, you can use the `associate` and `dissociate` methods.
To eventually write the changes to the database, save the parent object:
```php
```php
$user->books()->associate($book);
$user->books()->associate($book);
$user->save();
$user->save();
```
```
Like other relations, embedsMany assumes the local key of the relationship based on the model name. You can override the default local key by passing a second argument to the embedsMany method:
Like other relations, embedsMany assumes the local key of the relationship based on the model name. You can override the default local key by passing a second argument to the embedsMany method:
```php
```php
return$this->embedsMany('Book','local_key');
useJenssegers\Mongodb\Eloquent\Model;
classUserextendsModel
{
publicfunctionbooks()
{
return$this->embedsMany(Book::class,'local_key');
}
}
```
```
Embedded relations will return a Collection of embedded items instead of a query builder. Check out the available operations here: https://laravel.com/docs/master/collections
Embedded relations will return a Collection of embedded items instead of a query builder. Check out the available operations here: https://laravel.com/docs/master/collections
### EmbedsOne Relations
### EmbedsOne Relationship
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
```php
```php
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
useJenssegers\Mongodb\Eloquent\Model;
classBookextendsEloquent{
classBookextendsModel
{
publicfunctionauthor()
publicfunctionauthor()
{
{
return$this->embedsOne('Author');
return$this->embedsOne(Author::class);
}
}
}
}
```
```
You can access the embedded models through the dynamic property:
You can access the embedded models through the dynamic property:
```php
```php
$author=Book::first()->author;
$book=Book::first();
$author=$book->author;
```
```
Inserting and updating embedded models works similar to the `hasOne` relation:
Inserting and updating embedded models works similar to the `hasOne` relation:
You can update the embedded model using the `save` method (available since release 2.0.0):
You can update the embedded model using the `save` method (available since release 2.0.0):
...
@@ -915,178 +886,231 @@ You can replace the embedded model with a new model like this:
...
@@ -915,178 +886,231 @@ You can replace the embedded model with a new model like this:
```php
```php
$newAuthor=newAuthor(['name'=>'Jane Doe']);
$newAuthor=newAuthor(['name'=>'Jane Doe']);
$book->author()->save($newAuthor);
$book->author()->save($newAuthor);
```
```
### MySQL Relations
Query Builder
-------------
### Basic Usage
The database driver plugs right into the original query builder.
When using MongoDB connections, you will be able to build fluent queries to perform database operations.
If you're using a hybrid MongoDB and SQL setup, you're in luck! The model will automatically return a MongoDB- or SQL-relation based on the type of the related model. Of course, if you want this functionality to work both ways, your SQL-models will need use the `Jenssegers\Mongodb\Eloquent\HybridRelations` trait. Note that this functionality only works for hasOne, hasMany and belongsTo relations.
For your convenience, there is a `collection` alias for `table` as well as some additional MongoDB specific operators/operations.
Example SQL-based User model:
```php
```php
useJenssegers\Mongodb\Eloquent\HybridRelations;
$books = DB::collection('books')->get();
classUserextendsEloquent{
$hungerGames =
DB::collection('books')
->where('name', 'Hunger Games')
->first();
```
useHybridRelations;
If you are familiar with [Eloquent Queries](http://laravel.com/docs/queries), there is the same functionality.
protected$connection='mysql';
### Available operations
To see the available operations, check the [Eloquent](#eloquent) section.
publicfunctionmessages()
Schema
{
------
return$this->hasMany('Message');
The database driver also has (limited) schema builder support. You can easily manipulate collections and set indexes.
}
}
### Basic Usage
```php
Schema::create('users',function($collection){
$collection->index('name');
$collection->unique('email');
});
```
```
And the Mongodb-based Message model:
You can also pass all the parameters specified [in the MongoDB docs](https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options-for-all-index-types) to the `$options` parameter:
```php
```php
useJenssegers\Mongodb\Eloquent\ModelasEloquent;
Schema::create('users',function($collection){
$collection->index(
'username',
null,
null,
[
'sparse'=>true,
'unique'=>true,
'background'=>true,
]
);
});
```
classMessageextendsEloquent{
Inherited operations:
- create and drop
- collection
- hasCollection
- index and dropIndex (compound indexes supported as well)
- unique
protected$connection='mongodb';
MongoDB specific operations:
- background
- sparse
- expire
- geospatial
publicfunctionuser()
All other (unsupported) operations are implemented as dummy pass-through methods because MongoDB does not use a predefined schema.
{
return$this->belongsTo('User');
}
}
Read more about the schema builder on [Laravel Docs](https://laravel.com/docs/6.0/migrations#tables)
```
### Raw Expressions
### Geospatial indexes
These expressions will be injected directly into the query.
Geospatial indexes are handy for querying location-based documents.
They come in two forms: `2d` and `2dsphere`. Use the schema builder to add these to a collection.
You can also perform raw expressions on the internal MongoCollection object. If this is executed on the model class, it will return a collection of models. If this is executed on the query builder, it will return the original response.
In this new major release which supports the new MongoDB PHP extension, we also moved the location of the Model class and replaced the MySQL model class with a trait.
Please change all `Jenssegers\Mongodb\Model` references to `Jenssegers\Mongodb\Eloquent\Model` either at the top of your model files or your registered alias.
```php
```php
$user=User::where('name','John')->first();
useJenssegers\Mongodb\Eloquent\Model;
$user->unset('note');
classUserextendsModel
{
//
}
```
```
### Query Caching
If you are using hybrid relations, your MySQL classes should now extend the original Eloquent model class `Illuminate\Database\Eloquent\Model` instead of the removed `Jenssegers\Eloquent\Model`.
You may easily cache the results of a query using the remember method:
Instead use the new `Jenssegers\Mongodb\Eloquent\HybridRelations` trait. This should make things more clear as there is only one single model class in this package.
By default, Laravel keeps a log in memory of all queries that have been run for the current request. However, in some cases, such as when inserting a large number of rows, this can cause the application to use excess memory. To disable the log, you may use the `disableQueryLog` method:
Embedded relations now return an `Illuminate\Database\Eloquent\Collection` rather than a custom Collection class. If you were using one of the special methods that were available, convert them to Collection operations.