README.md 更新

master
Iwannamaybe 3 years ago
parent 476e1cda88
commit be584ed936

@ -29,7 +29,7 @@ Make sure you have the MongoDB PHP driver installed. You can find installation i
Installation using composer:
```
composer require jenssegers/mongodb
composer require ifornew/mongodb
```
### Laravel version Compatibility
@ -51,13 +51,13 @@ composer require jenssegers/mongodb
And add the service provider in `config/app.php`:
```php
Jenssegers\Mongodb\MongodbServiceProvider::class,
Ifornew\Mongodb\MongodbServiceProvider::class,
```
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`:
```php
$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
$app->register(Ifornew\Mongodb\MongodbServiceProvider::class);
$app->withEloquent();
```
@ -71,7 +71,7 @@ $capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
{
$config['name'] = $name;
return new Jenssegers\Mongodb\Connection($config);
return new Ifornew\Mongodb\Connection($config);
});
```
@ -82,18 +82,18 @@ Upgrading
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.
Please change all `Ifornew\Mongodb\Model` references to `Ifornew\Mongodb\Eloquent\Model` either at the top of your model files, or your registered alias.
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {}
```
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.
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 `Ifornew\Eloquent\Model`. Instead use the new `Ifornew\Mongodb\Eloquent\HybridRelations` trait. This should make things more clear as there is only one single model class in this package.
```php
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Ifornew\Mongodb\Eloquent\HybridRelations;
class User extends Eloquent {
@ -178,7 +178,7 @@ Eloquent
This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {}
```
@ -186,7 +186,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 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
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {
@ -198,7 +198,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.
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class MyModel extends Eloquent {
@ -214,7 +214,7 @@ Everything else (should) work just like the original Eloquent model. Read more a
You may also register an alias for the MongoDB model by adding the following to the alias array in `config/app.php`:
```php
'Moloquent' => Jenssegers\Mongodb\Eloquent\Model::class,
'Moloquent' => Ifornew\Mongodb\Eloquent\Model::class,
```
This will allow you to use the registered alias like:
@ -317,7 +317,7 @@ Extensions
If you want to use Laravel's native Auth functionality, register this included service provider:
```php
'Jenssegers\Mongodb\Auth\PasswordResetServiceProvider',
'Ifornew\Mongodb\Auth\PasswordResetServiceProvider',
```
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.
@ -348,7 +348,7 @@ If you want to use MongoDB to handle failed jobs, change the database in `config
And add the service provider in `config/app.php`:
```php
Jenssegers\Mongodb\MongodbQueueServiceProvider::class,
Ifornew\Mongodb\MongodbQueueServiceProvider::class,
```
### Sentry
@ -521,7 +521,7 @@ User::where('bmi', 30)->decrement('bmi', 1, ['category' => 'overweight']);
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:
```php
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use Ifornew\Mongodb\Eloquent\SoftDeletes;
class User extends Eloquent {
@ -720,7 +720,7 @@ Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate ob
Example:
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {
@ -749,7 +749,7 @@ Supported relations are:
Example:
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {
@ -764,7 +764,7 @@ class User extends Eloquent {
And the inverse relation:
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class Item extends Eloquent {
@ -779,7 +779,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`:
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {
@ -801,7 +801,7 @@ If you want to embed models, rather than referencing them, you can use the `embe
**REMEMBER**: these relations return Eloquent collections, they don't return query builder objects!
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent {
@ -878,7 +878,7 @@ Embedded relations will return a Collection of embedded items instead of a query
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class Book extends Eloquent {
@ -926,12 +926,12 @@ $book->author()->save($newAuthor);
### MySQL Relations
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.
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 `Ifornew\Mongodb\Eloquent\HybridRelations` trait. Note that this functionality only works for hasOne, hasMany and belongsTo relations.
Example SQL-based User model:
```php
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Ifornew\Mongodb\Eloquent\HybridRelations;
class User extends Eloquent {
@ -950,7 +950,7 @@ class User extends Eloquent {
And the Mongodb-based Message model:
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Ifornew\Mongodb\Eloquent\Model as Eloquent;
class Message extends Eloquent {

Loading…
Cancel
Save