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: CHANGELOG.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
# Changelog
2
2
All notable changes to this project will be documented in this file.
3
3
4
-
## [Unreleased]
4
+
## [4.0.0] - unreleased
5
5
6
+
- Rename package to `mongodb/laravel-eloquent`
7
+
- Change namespace to `Mongodb\Laravel`
6
8
- Add classes to cast `ObjectId` and `UUID` instances [#1](https://github.com/GromNaN/laravel-mongodb-private/pull/1) by [@alcaeus](https://github.com/alcaeus).
7
9
- Add `Query\Builder::toMql()` to simplify comprehensive query tests [#6](https://github.com/GromNaN/laravel-mongodb-private/pull/6) by [@GromNaN](https://github.com/GromNaN).
8
10
- Fix `Query\Builder::whereNot` to use MongoDB [`$not`](https://www.mongodb.com/docs/manual/reference/operator/query/not/) operator [#13](https://github.com/GromNaN/laravel-mongodb-private/pull/13) by [@GromNaN](https://github.com/GromNaN).
Copy file name to clipboardExpand all lines: CODE_OF_CONDUCT.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
39
39
40
40
## Enforcement
41
41
42
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hello@jenssegers.com. All complaints will be reviewed and investigated promptly and fairly.
42
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at community-conduct@mongodb.com. All complaints will be reviewed and investigated promptly and fairly.
43
43
44
44
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
45
@@ -81,4 +81,4 @@ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcem
81
81
[homepage]: https://www.contributor-covenant.org
82
82
83
83
For answers to common questions about this code of conduct, see the FAQ at
84
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
84
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
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.*
11
10
@@ -46,8 +45,6 @@ This package adds functionalities to the Eloquent model and Query builder for Mo
@@ -79,23 +76,23 @@ Make sure you have the MongoDB PHP driver installed. You can find installation i
79
76
Install the package via Composer:
80
77
81
78
```bash
82
-
$ composer require jenssegers/mongodb
79
+
$ composer require mongodb/laravel-eloquent
83
80
```
84
81
85
82
### Laravel
86
83
87
84
In case your Laravel version does NOT autoload the packages, add the service provider to `config/app.php`:
88
85
89
86
```php
90
-
Jenssegers\Mongodb\MongodbServiceProvider::class,
87
+
MongoDB\Laravel\MongodbServiceProvider::class,
91
88
```
92
89
93
90
### Lumen
94
91
95
92
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`:
return new Jenssegers\Mongodb\Connection($config);
112
+
return new MongoDB\Laravel\Connection($config);
116
113
});
117
114
```
118
115
@@ -186,7 +183,7 @@ Eloquent
186
183
This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
187
184
188
185
```php
189
-
use Jenssegers\Mongodb\Eloquent\Model;
186
+
use MongoDB\Laravel\Eloquent\Model;
190
187
191
188
class Book extends Model
192
189
{
@@ -199,7 +196,7 @@ Just like a normal model, the MongoDB model class will know which collection to
199
196
To change the collection, pass the `$collection` property:
200
197
201
198
```php
202
-
use Jenssegers\Mongodb\Eloquent\Model;
199
+
use MongoDB\Laravel\Eloquent\Model;
203
200
204
201
class Book extends Model
205
202
{
@@ -210,7 +207,7 @@ class Book extends Model
210
207
**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.
211
208
212
209
```php
213
-
use Jenssegers\Mongodb\Eloquent\Model;
210
+
use MongoDB\Laravel\Eloquent\Model;
214
211
215
212
class Book extends Model
216
213
{
@@ -224,7 +221,7 @@ Book::create(['id' => 1, 'title' => 'The Fault in Our Stars']);
224
221
Likewise, you may define a `connection` property to override the name of the database connection that should be used when utilizing the model.
225
222
226
223
```php
227
-
use Jenssegers\Mongodb\Eloquent\Model;
224
+
use MongoDB\Laravel\Eloquent\Model;
228
225
229
226
class Book extends Model
230
227
{
@@ -234,10 +231,10 @@ class Book extends Model
234
231
235
232
### Extending the Authenticatable base model
236
233
237
-
This package includes a MongoDB Authenticatable Eloquent class `Jenssegers\Mongodb\Auth\User` that you can use to replace the default Authenticatable class `Illuminate\Foundation\Auth\User` for your `User` model.
234
+
This package includes a MongoDB Authenticatable Eloquent class `MongoDB\Laravel\Auth\User` that you can use to replace the default Authenticatable class `Illuminate\Foundation\Auth\User` for your `User` model.
238
235
239
236
```php
240
-
use Jenssegers\Mongodb\Auth\User as Authenticatable;
237
+
use MongoDB\Laravel\Auth\User as Authenticatable;
241
238
242
239
class User extends Authenticatable
243
240
{
@@ -249,10 +246,10 @@ class User extends Authenticatable
249
246
250
247
When soft deleting a model, it is not actually removed from your database. Instead, a deleted_at timestamp is set on the record.
251
248
252
-
To enable soft deletes for a model, apply the `Jenssegers\Mongodb\Eloquent\SoftDeletes` Trait to the model:
249
+
To enable soft deletes for a model, apply the `MongoDB\Laravel\Eloquent\SoftDeletes` Trait to the model:
253
250
254
251
```php
255
-
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
252
+
use MongoDB\Laravel\Eloquent\SoftDeletes;
256
253
257
254
class User extends Model
258
255
{
@@ -274,7 +271,7 @@ Keep in mind guarding still works, but you may experience unexpected behavior.
274
271
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.
275
272
276
273
```php
277
-
use Jenssegers\Mongodb\Eloquent\Model;
274
+
use MongoDB\Laravel\Eloquent\Model;
278
275
279
276
class User extends Model
280
277
{
@@ -812,7 +809,7 @@ The MongoDB-specific relationships are:
812
809
Here is a small example:
813
810
814
811
```php
815
-
use Jenssegers\Mongodb\Eloquent\Model;
812
+
use MongoDB\Laravel\Eloquent\Model;
816
813
817
814
class User extends Model
818
815
{
@@ -826,7 +823,7 @@ class User extends Model
826
823
The inverse relation of `hasMany` is `belongsTo`:
827
824
828
825
```php
829
-
use Jenssegers\Mongodb\Eloquent\Model;
826
+
use MongoDB\Laravel\Eloquent\Model;
830
827
831
828
class Item extends Model
832
829
{
@@ -844,7 +841,7 @@ The belongsToMany relation will not use a pivot "table" but will push id's to a
844
841
If you want to define custom keys for your relation, set it to `null`:
845
842
846
843
```php
847
-
use Jenssegers\Mongodb\Eloquent\Model;
844
+
use MongoDB\Laravel\Eloquent\Model;
848
845
849
846
class User extends Model
850
847
{
@@ -864,7 +861,7 @@ If you want to embed models, rather than referencing them, you can use the `embe
864
861
**REMEMBER**: These relations return Eloquent collections, they don't return query builder objects!
865
862
866
863
```php
867
-
use Jenssegers\Mongodb\Eloquent\Model;
864
+
use MongoDB\Laravel\Eloquent\Model;
868
865
869
866
class User extends Model
870
867
{
@@ -936,7 +933,7 @@ $user->save();
936
933
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:
937
934
938
935
```php
939
-
use Jenssegers\Mongodb\Eloquent\Model;
936
+
use MongoDB\Laravel\Eloquent\Model;
940
937
941
938
class User extends Model
942
939
{
@@ -954,7 +951,7 @@ Embedded relations will return a Collection of embedded items instead of a query
954
951
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
955
952
956
953
```php
957
-
use Jenssegers\Mongodb\Eloquent\Model;
954
+
use MongoDB\Laravel\Eloquent\Model;
958
955
959
956
class Book extends Model
960
957
{
@@ -1156,14 +1153,14 @@ If you're using a hybrid MongoDB and SQL setup, you can define relationships acr
1156
1153
1157
1154
The model will automatically return a MongoDB-related or SQL-related relation based on the type of the related model.
1158
1155
1159
-
If you want this functionality to work both ways, your SQL-models will need to use the `Jenssegers\Mongodb\Eloquent\HybridRelations` trait.
1156
+
If you want this functionality to work both ways, your SQL-models will need to use the `MongoDB\Laravel\Eloquent\HybridRelations` trait.
1160
1157
1161
1158
**This functionality only works for `hasOne`, `hasMany` and `belongsTo`.**
1162
1159
1163
1160
The MySQL model should use the `HybridRelations` trait:
1164
1161
1165
1162
```php
1166
-
use Jenssegers\Mongodb\Eloquent\HybridRelations;
1163
+
use MongoDB\Laravel\Eloquent\HybridRelations;
1167
1164
1168
1165
class User extends Model
1169
1166
{
@@ -1181,7 +1178,7 @@ class User extends Model
1181
1178
Within your MongoDB model, you should define the relationship:
1182
1179
1183
1180
```php
1184
-
use Jenssegers\Mongodb\Eloquent\Model;
1181
+
use MongoDB\Laravel\Eloquent\Model;
1185
1182
1186
1183
class Message extends Model
1187
1184
{
@@ -1199,7 +1196,7 @@ class Message extends Model
1199
1196
If you want to use Laravel's native Auth functionality, register this included service provider:
With [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. You must however ensure that you add the following **after** the `MongodbServiceProvider` registration.
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.
1261
-
1262
-
Please change all `Jenssegers\Mongodb\Model` references to `Jenssegers\Mongodb\Eloquent\Model` either at the top of your model files or your registered alias.
1263
-
1264
-
```php
1265
-
use Jenssegers\Mongodb\Eloquent\Model;
1266
-
1267
-
class User extends Model
1268
-
{
1269
-
//
1270
-
}
1271
-
```
1243
+
#### Upgrading from version 3 to 4
1272
1244
1273
-
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`.
1274
-
1275
-
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.
1276
-
1277
-
```php
1278
-
use Jenssegers\Mongodb\Eloquent\HybridRelations;
1279
-
1280
-
class User extends Model
1281
-
{
1282
-
1283
-
use HybridRelations;
1284
-
1285
-
protected $connection = 'mysql';
1286
-
}
1287
-
```
1288
-
1289
-
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.
1290
-
1291
-
```php
1292
-
$books = $user->books()->sortBy('title')->get();
1293
-
```
1245
+
Change project name in composer.json to `mongodb/laravel` and run `composer update`.
1246
+
Change namespace from `Jenssegers\Mongodb` to `MongoDB\Laravel` in your models and config.
0 commit comments