A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Overview

Laravel MongoDB

Latest Stable Version Total Downloads Build Status codecov Donate

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.

Installation

Make sure you have the MongoDB PHP driver installed. You can find installation instructions at http://php.net/manual/en/mongodb.installation.php

Laravel version Compatibility

Laravel Package
4.2.x 2.0.x
5.0.x 2.1.x
5.1.x 2.2.x or 3.0.x
5.2.x 2.3.x or 3.0.x
5.3.x 3.1.x or 3.2.x
5.4.x 3.2.x
5.5.x 3.3.x
5.6.x 3.4.x
5.7.x 3.4.x
5.8.x 3.5.x
6.x 3.6.x
7.x 3.7.x
8.x 3.8.x

Install the package via Composer:

$ composer require jenssegers/mongodb

Laravel

In case your Laravel version does NOT autoload the packages, add the service provider to config/app.php:

Jenssegers\Mongodb\MongodbServiceProvider::class,

Lumen

For usage with Lumen, 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:

$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);

$app->withEloquent();

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 and add:

$capsule->getDatabaseManager()->extend('mongodb', function($config, $name) {
    $config['name'] = $name;

    return new Jenssegers\Mongodb\Connection($config);
});

Testing

To run the test for this package, run:

docker-compose up

Database Testing

To reset the database after each test, add:

use Illuminate\Foundation\Testing\DatabaseMigrations;

Also inside each test classes, add:

use DatabaseMigrations;

Keep in mind that these traits are not yet supported:

  • use Database Transactions;
  • use RefreshDatabase;

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:

'mongodb' => [
    'driver' => 'mongodb',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', 27017),
    'database' => env('DB_DATABASE', 'homestead'),
    'username' => env('DB_USERNAME', 'homestead'),
    'password' => env('DB_PASSWORD', 'secret'),
    'options' => [
        // 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+
    ],
],

For multiple servers or replica set configurations, set the host to an array and specify each server host:

'mongodb' => [
    'driver' => 'mongodb',
    'host' => ['server1', 'server2', ...],
    ...
    'options' => [
        'replicaSet' => 'rs0',
    ],
],

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/

'mongodb' => [
    'driver' => 'mongodb',
    'dsn' => env('DB_DSN'),
    'database' => env('DB_DATABASE', 'homestead'),
],

Eloquent

Extending the base model

This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.

use Jenssegers\Mongodb\Eloquent\Model;

class Book extends 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.

To change the collection, pass the $collection property:

use Jenssegers\Mongodb\Eloquent\Model;

class Book extends Model
{
    protected $collection = 'my_books_collection';
}

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.

use Jenssegers\Mongodb\Eloquent\Model;

class Book extends Model
{
    protected $primaryKey = 'id';
}

// Mongo will also create _id, but the 'id' property will be used for primary key actions like find().
Book::create(['id' => 1, 'title' => 'The Fault in Our Stars']);

Likewise, you may define a connection property to override the name of the database connection that should be used when utilizing the model.

use Jenssegers\Mongodb\Eloquent\Model;

class Book extends Model
{
    protected $connection = 'mongodb';
}

Extending the Authenticable base model

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.

use Jenssegers\Mongodb\Auth\User as Authenticatable;

class User extends Authenticatable
{

}

Soft Deletes

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 Jenssegers\Mongodb\Eloquent\SoftDeletes Trait to the model:

use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class User extends Model
{
    use SoftDeletes;

    protected $dates = ['deleted_at'];
}

For more information check Laravel Docs about Soft Deleting.

Guarding attributes

When choosing between guarding attributes or marking some as fillable, Taylor Otwell prefers the fillable route. This is in light of recent security issues described here.

Keep in mind guarding still works, but you may experience unexpected behavior.

Dates

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.

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    protected $dates = ['birthday'];
}

This allows you to execute queries like this:

$users = User::where(
    'birthday', '>',
    new DateTime('-18 years')
)->get();

Basic Usage

Retrieving all models

$users = User::all();

Retrieving a record by primary key

$user = User::find('517c43667db388101e00000f');

Where

$posts =
    Post::where('author.name', 'John')
        ->take(10)
        ->get();

OR Statements

$posts =
    Post::where('votes', '>', 0)
        ->orWhere('is_approved', true)
        ->get();

AND statements

$users =
    User::where('age', '>', 18)
        ->where('name', '!=', 'John')
        ->get();

whereIn

$users = User::whereIn('age', [16, 18, 20])->get();

When using whereNotIn objects will be returned if the field is non-existent. Combine with whereNotNull('age') to leave out those documents.

whereBetween

$posts = Post::whereBetween('votes', [1, 100])->get();

whereNull

$users = User::whereNull('age')->get();

Advanced wheres

$users =
    User::where('name', 'John')
        ->orWhere(function ($query) {
            return $query
                ->where('votes', '>', 100)
                ->where('title', '<>', 'Admin');
        })->get();

orderBy

$users = User::orderBy('age', 'desc')->get();

Offset & Limit (skip & take)

$users =
    User::skip(10)
        ->take(5)
        ->get();

groupBy

Selected columns that are not grouped will be aggregated with the $last function.

$users =
    Users::groupBy('title')
        ->get(['title', 'name']);

Distinct

Distinct requires a field for which to return the distinct values.

$users = User::distinct()->get(['name']);

// Equivalent to:
$users = User::distinct('name')->get();

Distinct can be combined with where:

$users =
    User::where('active', true)
        ->distinct('name')
        ->get();

Like

$spamComments = Comment::where('body', 'like', '%spam%')->get();

Aggregation

Aggregations are only available for MongoDB versions greater than 2.2.x

$total = Product::count();
$price = Product::max('price');
$price = Product::min('price');
$price = Product::avg('price');
$total = Product::sum('price');

Aggregations can be combined with where:

$sold = Orders::where('sold', true)->sum('price');

Aggregations can be also used on sub-documents:

$total = Order::max('suborder.price');

NOTE: This aggregation only works with single sub-documents (like EmbedsOne) not subdocument arrays (like EmbedsMany).

Incrementing/Decrementing the value of a column

Perform increments or decrements (default 1) on specified attributes:

Cat::where('name', 'Kitty')->increment('age');

Car::where('name', 'Toyota')->decrement('weight', 50);

The number of updated objects is returned:

$count = User::increment('age');

You may also specify additional columns to update:

Cat::where('age', 3)
    ->increment('age', 1, ['group' => 'Kitty Club']);

Car::where('weight', 300)
    ->decrement('weight', 100, ['latest_change' => 'carbon fiber']);

MongoDB-specific operators

Exists

Matches documents that have the specified field.

User::where('age', 'exists', true)->get();

All

Matches arrays that contain all elements specified in the query.

User::where('roles', 'all', ['moderator', 'author'])->get();

Size

Selects documents if the array field is a specified size.

Post::where('tags', 'size', 3)->get();

Regex

Selects documents where values match a specified regular expression.

use MongoDB\BSON\Regex;

User::where('name', 'regex', new Regex('.*doe', 'i'))->get();

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.

User::where('name', 'regexp', '/.*doe/i')->get();

The inverse of regexp:

User::where('name', 'not regexp', '/.*doe/i')->get();

Type

Selects documents if a field is of the specified type. For more information check: http://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type

User::where('age', 'type', 2)->get();

Mod

Performs a modulo operation on the value of a field and selects documents with a specified result.

User::where('age', 'mod', [10, 0])->get();

MongoDB-specific Geo operations

Near

$bars = Bar::where('location', 'near', [
    '$geometry' => [
        'type' => 'Point',
        'coordinates' => [
            -0.1367563, // longitude
            51.5100913, // latitude
        ],
    ],
    '$maxDistance' => 50,
])->get();

GeoWithin

$bars = Bar::where('location', 'geoWithin', [
    '$geometry' => [
        'type' => 'Polygon',
        'coordinates' => [
            [
                [-0.1450383, 51.5069158],
                [-0.1367563, 51.5100913],
                [-0.1270247, 51.5013233],
                [-0.1450383, 51.5069158],
            ],
        ],
    ],
])->get();

GeoIntersects

$bars = Bar::where('location', 'geoIntersects', [
    '$geometry' => [
        'type' => 'LineString',
        'coordinates' => [
            [-0.144044, 51.515215],
            [-0.129545, 51.507864],
        ],
    ],
])->get();

Inserts, updates and deletes

Inserting, updating and deleting records works just like the original Eloquent. Please check Laravel Docs' Eloquent section.

Here, only the MongoDB-specific operations are specified.

MongoDB specific operations

Raw Expressions

These expressions will be injected directly into the query.

User::whereRaw([
    'age' => ['$gt' => 30, '$lt' => 40],
])->get();

User::whereRaw([
    '$where' => '/.*123.*/.test(this.field)',
])->get();

User::whereRaw([
    '$where' => '/.*123.*/.test(this["hyphenated-field"])',
])->get();

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:

DB::collection('users')->timeout(-1)->get();

Upsert

Update or insert a document. Additional options for the update method are passed directly to the native update method.

// Query Builder
DB::collection('users')
    ->where('name', 'John')
    ->update($data, ['upsert' => true]);

// Eloquent
$user->update($data, ['upsert' => true]);

Projections

You can apply projections to your queries using the project method.

DB::collection('items')
    ->project(['tags' => ['$slice' => 1]])
    ->get();

DB::collection('items')
    ->project(['tags' => ['$slice' => [3, 7]]])
    ->get();

Projections with Pagination

$limit = 25;
$projections = ['id', 'name'];

DB::collection('items')
    ->paginate($limit, $projections);

Push

Add items to an array.

DB::collection('users')
    ->where('name', 'John')
    ->push('items', 'boots');

$user->push('items', 'boots');
DB::collection('users')
    ->where('name', 'John')
    ->push('messages', [
        'from' => 'Jane Doe',
        'message' => 'Hi John',
    ]);

$user->push('messages', [
    'from' => 'Jane Doe',
    'message' => 'Hi John',
]);

If you DON'T want duplicate items, set the third parameter to true:

DB::collection('users')
    ->where('name', 'John')
    ->push('items', 'boots', true);

$user->push('items', 'boots', true);

Pull

Remove an item from an array.

DB::collection('users')
    ->where('name', 'John')
    ->pull('items', 'boots');

$user->pull('items', 'boots');
DB::collection('users')
    ->where('name', 'John')
    ->pull('messages', [
        'from' => 'Jane Doe',
        'message' => 'Hi John',
    ]);

$user->pull('messages', [
    'from' => 'Jane Doe',
    'message' => 'Hi John',
]);

Unset

Remove one or more fields from a document.

DB::collection('users')
    ->where('name', 'John')
    ->unset('note');

$user->unset('note');

Relationships

Basic Usage

The only available relationships are:

  • hasOne
  • hasMany
  • belongsTo
  • belongsToMany

The MongoDB-specific relationships are:

  • embedsOne
  • embedsMany

Here is a small example:

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    public function items()
    {
        return $this->hasMany(Item::class);
    }
}

The inverse relation of hasMany is belongsTo:

use Jenssegers\Mongodb\Eloquent\Model;

class Item extends Model
{
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

belongsToMany and pivots

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:

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    public function groups()
    {
        return $this->belongsToMany(
            Group::class, null, 'user_ids', 'group_ids'
        );
    }
}

EmbedsMany Relationship

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!

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    public function books()
    {
        return $this->embedsMany(Book::class);
    }
}

You can access the embedded models through the dynamic property:

$user = User::first();

foreach ($user->books as $book) {
    //
}

The inverse relation is automagically available. You don't need to define this reverse relation.

$book = Book::first();

$user = $book->user;

Inserting and updating embedded models works similar to the hasMany relation:

$book = $user->books()->save(
    new Book(['title' => 'A Game of Thrones'])
);

// or
$book =
    $user->books()
         ->create(['title' => 'A Game of Thrones']);

You can update embedded models using their save method (available since release 2.0.0):

$book = $user->books()->first();

$book->title = 'A Game of Thrones';
$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):

$book->delete();

// Similar operation
$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:

$user->books()->associate($book);
$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:

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    public function books()
    {
        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

EmbedsOne Relationship

The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.

use Jenssegers\Mongodb\Eloquent\Model;

class Book extends Model
{
    public function author()
    {
        return $this->embedsOne(Author::class);
    }
}

You can access the embedded models through the dynamic property:

$book = Book::first();
$author = $book->author;

Inserting and updating embedded models works similar to the hasOne relation:

$author = $book->author()->save(
    new Author(['name' => 'John Doe'])
);

// Similar
$author =
    $book->author()
         ->create(['name' => 'John Doe']);

You can update the embedded model using the save method (available since release 2.0.0):

$author = $book->author;

$author->name = 'Jane Doe';
$author->save();

You can replace the embedded model with a new model like this:

$newAuthor = new Author(['name' => 'Jane Doe']);

$book->author()->save($newAuthor);

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.

For your convenience, there is a collection alias for table as well as some additional MongoDB specific operators/operations.

$books = DB::collection('books')->get();

$hungerGames =
    DB::collection('books')
        ->where('name', 'Hunger Games')
        ->first();

If you are familiar with Eloquent Queries, there is the same functionality.

Available operations

To see the available operations, check the Eloquent section.

Schema

The database driver also has (limited) schema builder support. You can easily manipulate collections and set indexes.

Basic Usage

Schema::create('users', function ($collection) {
    $collection->index('name');
    $collection->unique('email');
});

You can also pass all the parameters specified in the MongoDB docs to the $options parameter:

Schema::create('users', function ($collection) {
    $collection->index(
        'username',
        null,
        null,
        [
            'sparse' => true,
            'unique' => true,
            'background' => true,
        ]
    );
});

Inherited operations:

  • create and drop
  • collection
  • hasCollection
  • index and dropIndex (compound indexes supported as well)
  • unique

MongoDB specific operations:

  • background
  • sparse
  • expire
  • geospatial

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 Laravel Docs

Geospatial indexes

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.

Schema::create('bars', function ($collection) {
    $collection->geospatial('location', '2d');
});

To add a 2dsphere index:

Schema::create('bars', function ($collection) {
    $collection->geospatial('location', '2dsphere');
});

Extending

Cross-Database Relationships

If you're using a hybrid MongoDB and SQL setup, you can define relationships across them.

The model will automatically return a MongoDB-related or SQL-related relation based on the type of the related model.

If you want this functionality to work both ways, your SQL-models will need to use the Jenssegers\Mongodb\Eloquent\HybridRelations trait.

This functionality only works for hasOne, hasMany and belongsTo.

The MySQL model should use the HybridRelations trait:

use Jenssegers\Mongodb\Eloquent\HybridRelations;

class User extends Model
{
    use HybridRelations;

    protected $connection = 'mysql';

    public function messages()
    {
        return $this->hasMany(Message::class);
    }
}

Within your MongoDB model, you should define the relationship:

use Jenssegers\Mongodb\Eloquent\Model;

class Message extends Model
{
    protected $connection = 'mongodb';

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

Authentication

If you want to use Laravel's native Auth functionality, register this included service provider:

Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,

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.

Queues

If you want to use MongoDB as your database backend, change the driver in config/queue.php:

'connections' => [
    'database' => [
        'driver' => 'mongodb',
        // You can also specify your jobs specific database created on config/database.php
        'connection' => 'mongodb-job',
        'table' => 'jobs',
        'queue' => 'default',
        'expire' => 60,
    ],
],

If you want to use MongoDB to handle failed jobs, change the database in config/queue.php:

'failed' => [
    'driver' => 'mongodb',
    // You can also specify your jobs specific database created on config/database.php
    'database' => 'mongodb-job',
    'table' => 'failed_jobs',
],

Laravel specific

Add the service provider in config/app.php:

Jenssegers\Mongodb\MongodbQueueServiceProvider::class,

Lumen specific

With Lumen, add the service provider in bootstrap/app.php. You must however ensure that you add the following after the MongodbServiceProvider registration.

$app->make('queue');

$app->register(Jenssegers\Mongodb\MongodbQueueServiceProvider::class);

Upgrading

Upgrading from version 2 to 3

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.

use Jenssegers\Mongodb\Eloquent\Model;

class User extends Model
{
    //
}

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.

use Jenssegers\Mongodb\Eloquent\HybridRelations;

class User extends Model
{

    use HybridRelations;

    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.

$books = $user->books()->sortBy('title')->get();

Security contact information

To report a security vulnerability, follow these steps.

Comments
  • Add transaction support

    Add transaction support

    requires mongodb version V4.0 or more and deployment replica sets or sharded clusters transaction support create/insert,update,delete,etc operation Supports infinite-level nested transactions, but outside transaction rollbacks do not affect the commit of inside transactions

    DB::beginTransaction();
    DB::collection('users')->where('name', 'klinson')->update(['age' => 18]);
    DB::transaction(function () {
        DB::collection('users')->where('name', 'mongodb')->update(['age' => 30]);
    });
    DB::rollBack();
    
    Needs work 
    opened by klinson 46
  • Database Transactions not working

    Database Transactions not working

    Hello everyone, i stumbled on this issue today:

    When i try to use laravel's transactions like this

    DB::transaction(function() use($data) {
            $this->repository->create($data);
    });
    

    I get the following:

    Call to a member function beginTransaction() on null
    /vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:108
    /vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:92
    /vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:23
    /vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:327
    /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
    

    I'm using laravel 5.4 and php version 7.1.

    Is there any workaround for this issue?

    This package is helping me out a lot with my personal project and i guess there is no other option for laravel and mongodb, so anything that solves it will do for me i guess.

    duplicate enhancement 
    opened by klferreira 40
  • Composer can't find mongodb extension

    Composer can't find mongodb extension

    Hi - I'm running into essentially the same error as in issue #780 when executing composer require jenssegers/mongodb:

    $ composer require jenssegers/mongodb
    Using version ^3.0 for jenssegers/mongodb
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - jenssegers/mongodb v3.0.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
        - jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
        - jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
        - mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
        - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
        - Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2].
    
      To enable extensions, verify that they are enabled in those .ini files:
        - C:\Program Files\PHP\v7.0\php.ini
      You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
    
    Installation failed, reverting ./composer.json to its original content.
    

    I'm running Windows 10 and PHP 7. I installed the mongodb extension (php_mongodb.dll in PHP ext/ folder), and I've updated php.ini with extension=php_mongodb.dll. Not sure what I've missed. If anyone can help me with this, I'd greatly appreciate it. Thanks.

    opened by supaheckafresh 40
  • Class 'MongoClient' not found?

    Class 'MongoClient' not found?

    Class 'MongoClient' not found in Connection.php on line 132. This is the error received when I try to run migrations - ($ php artisan migrate). Any Ideas? Thanks in advance.

    opened by Cein-Markey 35
  • Class 'MongoDB\Driver\Manager' not found

    Class 'MongoDB\Driver\Manager' not found

    Hello, I'm using Php7.1, Laravel 5.5, and Mongo 3.4.10 as Dockers.

    In the .../vendor/mongodb/mongodb/src/Client.php file, the corresponding FatalThrowableError Class 'MongoDB\Driver\Manager' not found appears on line 83.

    In the Model

    <? php
    
    namespace App\Models\Mongo;
    
    use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
    
    class Keywords extends Moloquent
    {
         protected $connection = 'mongodb';
         protected $collection = 'keywords';
    }
    

    I used the code,

    In the Controller,

    public function keyword ()
    {
         Keywords::all();
    }
    

    I used the code.

    The database.php file contains

    'mongodb' => [
         'driver' => 'mongodb',
         'host' => '127.0.0.1',
         'port' => '27017',
         'database' => 'test',
    ],
    

    I put this code in it.

    I've been looking for the same error since yesterday, but it's still the same. Help is urgently needed.

    duplicate question 
    opened by lzao 31
  • When I try to reset my password I get this error: FatalThrowableError in Carbon.php line 291: Type error: DateTime::__construct() expects parameter 1 to be string, array given

    When I try to reset my password I get this error: FatalThrowableError in Carbon.php line 291: Type error: DateTime::__construct() expects parameter 1 to be string, array given

    Hello guys, every time I try to reset my psw I get this error. Using Laravel with MongoDB:

    Thanks in advance for the answers

    in Carbon.php line 291 at DateTime->__construct(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'), object(DateTimeZone)) in Carbon.php line 291 at Carbon->__construct(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'), null) in Carbon.php line 324 at Carbon::parse(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC')) in DatabaseTokenRepository.php line 126 at DatabaseTokenRepository->tokenExpired(array('_id' => object(ObjectID), 'email' => '[email protected]', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4', 'created_at' => array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'))) in DatabaseTokenRepository.php line 115 at DatabaseTokenRepository->exists(object(User), array('_id' => object(ObjectID), 'email' => '[email protected]', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4', 'created_at' => array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'))) in PasswordBroker.php line 122 at PasswordBroker->validateReset(array('email' => '[email protected]', 'password' => 'Alessaalessa656', 'password_confirmation' => 'Alessaalessa656', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4')) in PasswordBroker.php line 88 at PasswordBroker->reset(array('email' => '[email protected]', 'password' => 'Alessaalessa656', 'password_confirmation' => 'Alessaalessa656', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4'), object(Closure)) in ResetsPasswords.php line 46 at ResetPasswordController->reset(object(Request)) at call_user_func_array(array(object(ResetPasswordController), 'reset'), array(object(Request))) in Controller.php line 55 at Controller->callAction('reset', array(object(Request))) in ControllerDispatcher.php line 44 at ControllerDispatcher->dispatch(object(Route), object(ResetPasswordController), 'reset') in Route.php line 189 at Route->runController() in Route.php line 144 at Route->run(object(Request)) in Router.php line 653 at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24 at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41 at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65 at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64 at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Router.php line 655 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629 at Router->dispatchToRoute(object(Request)) in Router.php line 607 at Router->dispatch(object(Request)) in Kernel.php line 268 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Kernel.php line 150 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117 at Kernel->handle(object(Request)) in index.php line 53 at require('/Users/alessandro/Documents/Programmazione/Laravel/ASAP/public/index.php') in server.php line 133

    bug fixed 
    opened by McMazalf 29
  • Authentication failed in Laravel 5.2

    Authentication failed in Laravel 5.2

    Hello all,

    I received a Authentication failed message with Laravel 5.2 when I ran my following controller. My MongoDB server don't require an authentication for a connection to any databases. How should I do to fix it?

    Many thanks for your help,

    My TestController controller:

    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    
    use App\Http\Requests;
    
    class TestController extends Controller
    {
    
        public function test() {
            return \App\Models\Test::all();
        }
    }
    

    My config\database.php:

    'mongodb' => [
                'driver'   => 'mongodb',
                'host'     => env('DB_HOST', 'localhost'),
                'port'     => env('DB_PORT', 27017),
                'database' => env('DB_DATABASE', 'myproject'),
                'username' => env('DB_USERNAME', ''),
                'password' => env('DB_PASSWORD', ''),
                'options' => [
                    'db' => 'admin' // sets the authentication database required by mongo 3
                ]
            ],
    

    My .env file:

    DB_HOST=127.0.0.1
    DB_DATABASE=myproject
    DB_USERNAME=
    DB_PASSWORD=
    

    My Test model:

    namespace App\Models;
    
    use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
    
    class Test extends Eloquent
    {
        //protected $connection = 'myproject';
    
    }
    

    My environment:

    • Laravel 5.2
    • jenssegers/mongodb 3.0.1
    • php_mongodb 1.1.2 in PHP 5.6
    opened by phongtnit 27
  • Proposal about new maintainers

    Proposal about new maintainers

    @jenssegers, library has pending PR's waiting review one month and more, old docs, broken ci in travis, many issues without answers for community. I propose to find new maintainers from community, if you don't have enough time to maintance this library. Any can fork and improve separately but I think that community can improve this library if maintainers will have enough time for maintance.

    With regards, Smolevich

    question 
    opened by Smolevich 24
  • Cast data before saving it into database and mongoId as Relationships

    Cast data before saving it into database and mongoId as Relationships

    in this PR i modify the eloquent cast part to cast data before saving it into DB. in project its difficult to cast data properly before saving it i add $saveCasts into model that can be filled just $cast mainly it use $saveCasts to cast Relationships into mongoId. the mongoId as Relationships part can be activated by setting "use_mongo_id":

            'mongodb' => [
                'name'         => 'mongodb',
                'driver'       => 'mongodb',
                'host'         => '127.0.0.1',
                'database'     => 'unittest',
                'use_mongo_id' => true,
            ]
    

    also this PR contains new test's for use_mongo_id part and some fixes to make it work with mongoIds

    opened by RTLer 24
  • Error when user registration -> Call to a member function prepare() on null

    Error when user registration -> Call to a member function prepare() on null

    Dear programmers, I just using this package for my project I have done configurations in this readme file.

    But when I use Laravel default Auth, and user want to register, it says :

    "Call to a member function prepare() on null" "at Connection->Illuminate\Database{closure}('insert into "users" ("name", "email", "password", "updated_at", "created_at") values (?, ?, ?, ?, ?)', array(.............." "in Connection.php (line 640)"

    Please help me how to solve it

    opened by adnanfajr 23
  • Incompatibility with new mongodb driver?

    Incompatibility with new mongodb driver?

    Hi, The driver works fine with the legacy pecl mongodb driver: https://pecl.php.net/package/mongo

    However, it looks like there is incompatibility with the new driver: https://pecl.php.net/package/mongodb

    More info about the two drivers here: https://docs.mongodb.org/ecosystem/drivers/php/

    Any pointers?

    Thank you

    opened by wissamk 23
  • Query error

    Query error

    • Laravel-mongodb Version: #.#.#
    • PHP Version: 8.2.0
    • Database Driver & Version:3.4.4

    Description:

    i don t speak englinsh,so zhi tie chu le baocuo xinxi

    Steps to reproduce

    1.ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900 2.ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900 3.ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900

    Expected behaviour

    ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900

    Actual behaviour

    ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900

    Logs: ErrorException: Use of "parent" in callables is deprecated in /www/webman/vendor/jenssegers/mongodb/src/Query/Builder.php:900
    opened by wo642436249 0
  • Querying subdocuments using whereIn by

    Querying subdocuments using whereIn by "_id" field does not work, yet it does by "id" key

    Description:

    Querying using whereIn("subarray._id", [...]) does not work, when subarray has an array of items with '_id' field. If you had subarray of items with 'id' instead of '_id' and then queried for "subarray.id" it would work. However querying using whereRaw(['subarray._id' => ['$in' => ['id_value'']]]) works as expected. I tried transforming the array of _id strings into an array of ObjectIds but it didn't help.

    Steps to reproduce

    1. Create a document with a subarray of items where each item will have an _id field
    2. Try a query using whereIn("subarray._id", [...]) = will not return results
    3. Now do the same but create a document with a subarray of items where each item will have an id field
    4. Try a query using whereIn("subarray.id", [...]) = will return results

    Expected behaviour

    It should work as normal, as in step 4

    Actual behaviour

    It returned no results while there definitely were matches

    opened by fidan-mkdir 0
  •  MongoDB\Driver\Exception\CommandException

    MongoDB\Driver\Exception\CommandException

    Good day!

    • Laravel-mongodb Version: 3.8
    • PHP Version: 8.1
    • Database Driver & Version: 1.15

    Description:

    PS D:\www\backend> php artisan migrate
    Migrating: 2020_03_20_185032_create_jobs_table
    
       MongoDB\Driver\Exception\CommandException
    
      Collection mydb.jobs already exists.
    
      at D:\www\backend\vendor\mongodb\mongodb\src\Operation\CreateCollection.php:273
        269▕      * @throws DriverRuntimeException for other driver errors (e.g. connection errors)
        270▕      */
        271▕     public function execute(Server $server)
        272▕     {
      ➜ 273▕         $cursor = $server->executeWriteCommand($this->databaseName, $this->createCommand(), $this->createOptions());
        274▕
        275▕         if (isset($this->options['typeMap'])) {
        276▕             $cursor->setTypeMap($this->options['typeMap']);
        277▕         }
    
      1   D:\www\backend\vendor\mongodb\mongodb\src\Operation\CreateCollection.php:273
          MongoDB\Driver\Server::executeWriteCommand("mydb", Object(MongoDB\Driver\Command), [])
    
      2   D:\www\backend\vendor\mongodb\mongodb\src\Database.php:294
          MongoDB\Operation\CreateCollection::execute(Object(MongoDB\Driver\Server))
    
    opened by itsrexb 2
  • LIKE breaks when the search condition ends with \

    LIKE breaks when the search condition ends with \

    In \Jenssegers\Mongodb\Query\Builder::compileWhereBasic, https://github.com/jenssegers/laravel-mongodb/blob/e5e91936b7537354672df27e7cfbeec7fa2fb2d1/src/Query/Builder.php#L1046

    This was added as a fix for https://github.com/jenssegers/laravel-mongodb/issues/719

    the regex explicitly looks for pattern that starts with % or having a percentage that is just after any character but a backslash.

    Could you please provide the reason why that was implemented like this. I am trying to search in mongodb for a substring that ends with backslash and it doesn't generate the correct regex.

    would you agree a more generic regex like '#(^|.)%#' is more suited here?

    opened by RichuJohn 2
  • same record appearing on different pages

    same record appearing on different pages

    • Laravel-mongodb Version: v3.6.8
    • PHP Version:7.4
    • Database Driver & Version: 1.14.0 & v4.4.18

    Description:

    when calling orderBy() and limit(), offset() the same record appears at the end of a page and at the beginning of another

    Steps to reproduce

    1. $query = $this->newQuery();
    2. $query->orderBy('field', 'desc');
    3. $query->limit($maxPerPage)->offset($skip);

    image

    Expected behaviour

    bring the results correctly filtered and sorted without duplicating data on different pages

    Actual behaviour

    the same record appears at the end of a page and at the beginning of another

    Result call first page

    {
        "code": 200,
        "status": true,
        "data": {
            "pagination": {
                "totalItens": 31,
                "page": 2,
                "totalPages": 4,
                "nextPage": 3,
                "prevPage": null
            },
            "ordination": {
                "options": [
                    {
                        "key": "price_asc",
                        "value": "Menor preço"
                    },
                    {
                        "key": "price_desc",
                        "value": "Maior preço"
                    },
                    {
                        "key": "soldAmount_desc",
                        "value": "Mais vendido"
                    },
                    {
                        "key": "id_desc",
                        "value": "Lançamento"
                    },
                    {
                        "key": "name_asc",
                        "value": "Ordem alfabética A > Z"
                    },
                    {
                        "key": "name_desc",
                        "value": "Ordem alfabética Z > A"
                    }
                ],
                "selected": {
                    "key": "soldAmount_desc",
                    "value": "Mais vendido"
                }
            },
            "filtersApplieds": [],
            "itens": [
                {
                    "id": 114,
                    "name": "Camisa Jogador Listra No Ombro Preta",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/4dcccf6b136283bf.jpg"
                },
                {
                    "id": 31,
                    "name": "Camisa Jogador Utan Silk Preta",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/992d7da5ca7d7462.jpg"
                },
                {
                    "id": 117,
                    "name": "Camisa Jogador Listra No Ombro Vermelha",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/e78933f983307c08.jpg"
                },
                {
                    "id": 30,
                    "name": "Camisa Jogador Utan Silk Rosa Bebê",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/dcd9cf07ca03737e.jpg"
                },
                {
                    "id": 14,
                    "name": "Camisa Jogador Utan Bordado Vermelha",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/5ce6d9b19e479b68.jpg"
                },
                {
                    "id": 126,
                    "name": "Camisa Jogador Larga Minha Camisa Preta",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/151cd6acdc679163.jpg"
                },
                {
                    "id": 12,
                    "name": "Camisa Jogador Utan Na Gola Lilas",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/62416eb6d8259965.jpg"
                },
                {
                    "id": 16,
                    "name": "Camisa Jogador Utan Na Gola Marrom Escuro",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/99d989a5a3c1bdd7.jpg"
                },
                {
                    "id": 79,
                    "name": "Camisa Jogador Branca Assinatura Brasil",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/5cb70d5d41c6efdc.jpg"
                },
                {
                    "id": 80,
                    "name": "Camisa Jogador Preta Assinatura Brasil",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/0c9b847d091db934.jpg"
                }
            ],
            "term": null
        },
        "errorMsg": ""
    }
    

    Result call second page

    {
        "code": 200,
        "status": true,
        "data": {
            "pagination": {
                "totalItens": 31,
                "page": 3,
                "totalPages": 4,
                "nextPage": 4,
                "prevPage": null
            },
            "ordination": {
                "options": [
                    {
                        "key": "price_asc",
                        "value": "Menor preço"
                    },
                    {
                        "key": "price_desc",
                        "value": "Maior preço"
                    },
                    {
                        "key": "soldAmount_desc",
                        "value": "Mais vendido"
                    },
                    {
                        "key": "id_desc",
                        "value": "Lançamento"
                    },
                    {
                        "key": "name_asc",
                        "value": "Ordem alfabética A > Z"
                    },
                    {
                        "key": "name_desc",
                        "value": "Ordem alfabética Z > A"
                    }
                ],
                "selected": {
                    "key": "soldAmount_desc",
                    "value": "Mais vendido"
                }
            },
            "filtersApplieds": [],
            "itens": [
                {
                    "id": 79,
                    "name": "Camisa Jogador Branca Assinatura Brasil",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/5cb70d5d41c6efdc.jpg"
                },
                {
                    "id": 80,
                    "name": "Camisa Jogador Preta Assinatura Brasil",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/0c9b847d091db934.jpg"
                },
                {
                    "id": 132,
                    "name": "Camisa Jogador Utan Na Gola Preta",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/ee2556a67974c695.jpg"
                },
                {
                    "id": 28,
                    "name": "Camisa Jogador Utan Silk Branca",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/6a4bc86182b1ccc0.jpg"
                },
                {
                    "id": 100,
                    "name": "Camisa Jogador Utan Bordado Marfim",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/68cde638731e552f.jpg"
                },
                {
                    "id": 203,
                    "name": "Cam Jog ListraNoOmbro Rosa Bebe",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/ddd4d97a02bd2c21.jpg"
                },
                {
                    "id": 10,
                    "name": "Camisa Jogador Utan Bordado Verde Destonado",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/182691ae15ff8086.jpg"
                },
                {
                    "id": 101,
                    "name": "Camisa Jogador Utan Bordado AzulBebe",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/73326c92cd0a3186.jpg"
                },
                {
                    "id": 29,
                    "name": "Camisa Jogador Utan Silk Verde Destonado",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/69f1f8a37eef8cbc.jpg"
                },
                {
                    "id": 103,
                    "name": "Camisa Jogador Utan Bordado Jeans",
                    "price": 90,
                    "promotionPrice": 0,
                    "paymentDescription": "",
                    "tags": [],
                    "image": "https://cdn.mobilestores.app/203/products/bb363cdd2fc97913.jpg"
                }
            ],
            "term": null
        },
        "errorMsg": ""
    }
    
    opened by ceresaconsultoria 0
Releases(v3.9.2)
  • v3.9.2(Sep 1, 2022)

  • v3.8.5(Jul 14, 2022)

  • v3.9.1(Jun 30, 2022)

  • v3.9.0(Feb 17, 2022)

  • 3.8.4(May 27, 2021)

    • Add doesntExist to passthru https://github.com/jenssegers/laravel-mongodb/pull/2194
    • Fix getRelationQuery breaking changes https://github.com/jenssegers/laravel-mongodb/pull/2263
    • Add Model query whereDate support https://github.com/jenssegers/laravel-mongodb/pull/2251
    • Add transaction free deleteAndRelease() method https://github.com/jenssegers/laravel-mongodb/pull/2229
    • Add setDatabase to Jenssegers\Mongodb\Connection https://github.com/jenssegers/laravel-mongodb/pull/2236
    • Check dates against DateTimeInterface instead of DateTime https://github.com/jenssegers/laravel-mongodb/pull/2239
    • Move from psr-0 to psr-4 https://github.com/jenssegers/laravel-mongodb/pull/2247
    • Apply fixes produced by php-cs-fixer https://github.com/jenssegers/laravel-mongodb/pull/2250
    Source code(tar.gz)
    Source code(zip)
  • v3.8.3(Feb 21, 2021)

  • v3.6.8(Feb 21, 2021)

  • v3.7.3(Feb 21, 2021)

  • v3.8.2(Dec 18, 2020)

  • v3.7.2(Dec 18, 2020)

  • v3.6.7(Dec 18, 2020)

  • v3.7.1(Oct 29, 2020)

  • v3.6.6(Oct 29, 2020)

  • v3.8.1(Oct 23, 2020)

  • v3.3.2(Oct 15, 2020)

  • v3.8.0(Sep 30, 2020)

  • v3.7.0(Sep 18, 2020)

  • v3.6.5(Aug 26, 2020)

    Fix bugs and small improvements

    • Fix truncate to delete items in collection (#1993)
    • Fix always call connection to broadcast QueryExecuted event (#2024 )
    • Fix laravel guarded error (#2082)
    Source code(tar.gz)
    Source code(zip)
  • v3.6.4(Apr 23, 2020)

    Fix bugs and small improvements

    • Fix issue parsing millisecond-precision dates before 1970. (#2028 )
    • Add cursor (#2024 )
    • Query like on integer fields (#2020)
    • Fix refresh() on EmbedsOne (#1996 )
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-alpha.1(Apr 23, 2020)

  • v3.6.3(Mar 4, 2020)

    • Fix laravel 6 compatibility (https://github.com/jenssegers/laravel-mongodb/pull/1979)
    • Fix getDefaultDatabaseName to handle +srv URLs (https://github.com/jenssegers/laravel-mongodb/pull/1976)
    Source code(tar.gz)
    Source code(zip)
  • v3.6.2(Feb 27, 2020)

    • Added new logic for HybridRelations::morphTo (https://github.com/jenssegers/laravel-mongodb/pull/1835)
    • Added using Carbon::now() (https://github.com/jenssegers/laravel-mongodb/pull/1870)
    • UTCDateTime conversion now includes milliseconds (https://github.com/jenssegers/laravel-mongodb/pull/1966)
    • Added $localKey parameter for hasOne and hasMany (https://github.com/jenssegers/laravel-mongodb/pull/1837)
    • Add MustVerifyEmail trait https://github.com/jenssegers/laravel-mongodb/pull/1933)
    • Allow setting hint option on QueryBuilder (https://github.com/jenssegers/laravel-mongodb/pull/1939)
    • Fix Convert UTCDateTime to a date string when reset password (https://github.com/jenssegers/laravel-mongodb/pull/1903)
    • Fix truncate on models (https://github.com/jenssegers/laravel-mongodb/pull/1949)
    • Fix Carbon import (https://github.com/jenssegers/laravel-mongodb/pull/1964)
    • Fix get database name from dsn(https://github.com/jenssegers/laravel-mongodb/pull/1954)
    • Fix paginate in EmbedsMany (https://github.com/jenssegers/laravel-mongodb/pull/1959)
    • Fix format exception to string in failed jobs (https://github.com/jenssegers/laravel-mongodb/pull/1961)
    • Fix correct import class for db in queue (https://github.com/jenssegers/laravel-mongodb/pull/1968)
    • Fix default database detection from dsn (https://github.com/jenssegers/laravel-mongodb/pull/1971)
    • Fix create collection with options (https://github.com/jenssegers/laravel-mongodb/pull/1953)
    Source code(tar.gz)
    Source code(zip)
  • v3.6.1(Oct 31, 2019)

  • v3.6.0(Sep 8, 2019)

  • v3.5.3(Aug 21, 2019)

  • v3.5.2(Aug 1, 2019)

  • v3.5.1(Mar 12, 2019)

  • v3.5.0(Feb 27, 2019)

  • v3.4.5(Dec 5, 2018)

Owner
Jens Segers
Head of Engineering at CHEQROOM
Jens Segers
Eloquent MongoDB Repository Implementation

Eloquent MongoDB Repository Eloquent MongoDB Repository using nilportugues/repository as foundation, using jenssegers/mongodb. Installation Use Compos

Nil Portugués Calderó 18 Feb 12, 2022
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

null 3 Feb 14, 2022
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Idiorm http://j4mie.github.com/idiormandparis/ Feature/API complete Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it wil

Jamie Matthews 2k Dec 27, 2022
SQL to Laravel Query Builder

Marwan - SQL To Laravel Builder SQL to Laravel Query Builder, A Converter written in PHP Features Converts SQL Queries to Laravel Query Builder. Assis

Rexhep Shijaku 162 Dec 19, 2022
Get MYSQL statement from query builder in laravel helper

Get MYSQL statement laravel This package allows to get mysql statement that query builder in laravel made it for debugging purposes. Basic usage Dump

Ahmed Helal 9 Jul 15, 2022
A SQL query builder with zero dependencies

Latitude Query Builder A SQL query builder with zero dependencies. Attempts to be PSR-1, PSR-2, and PSR-4 compliant. Install composer require latitude

Woody Gilk 618 Dec 30, 2022
Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Kodols 9 Dec 22, 2022
Migrations for MongoDB based on PHPMongo ODM

PHPMongo Migrator Migrations for MongoDB based on PHPMongo ODM Schema not required in MongoDb, so we dont need to create databases, collections or alt

Sokil 29 Jul 13, 2022
Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter Eloquent Filter adds custom filters to your Eloquent Models in Laravel. It's easy to use and fully dynamic. Table of Content Introduct

Mehdi Fathi 327 Dec 28, 2022
Easily exclude model entities from eloquent queries

Laravel Excludable Easily exclude model entities from eloquent queries. This package allows you to define a subset of model entities who should be exc

H-FARM 49 Jan 4, 2023
MongoDB ORM that includes support for references,embed and multilevel inheritance.

Introduction Features Requirements Installation Setup Database Basic Usage - CRUD Relationship - Reference Relationship - Embed Collection Inheritance

Michael Gan 202 Nov 17, 2022
Extend Jenssegers/laravel-mongodb to support transaction function

Laravel Mongodb (Transactional support) Introduction Jensseger's laravel-mongodb extension package is very popular among Laravel developers, but it la

Iman RJ 10 Nov 1, 2022
MongoDB PHP library

MongoDB PHP Library This library provides a high-level abstraction around the lower-level PHP driver (mongodb extension). While the extension provides

mongodb 1.5k Dec 31, 2022
Psalm Stubs for doctrine/mongodb-odm library

doctrine-mongodb-psalm-plugin A Doctrine plugin for Psalm (requires Psalm v4). Installation: $ composer require --dev runtothefather/doctrine-mongodb-

Evgeny 6 Jun 15, 2022
Simple MongoDB API for PHP!

SimpleMongo SimpleMongo is a simple API for MongoDB, written in PHP. How to use? First of all, copy SimpleMongo.php into your project and fill the fir

AlicanCopur 9 Jul 19, 2021
RockMongo is a MongoDB administration tool, written in PHP 5.

Introduction -------------------------------------- RockMongo is a MongoDB administration tool, written in PHP 5, very easy to install and use. Inst

Liu Xiangchao 1k Dec 27, 2022
Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.

Aura.SqlQuery Provides query builders for MySQL, Postgres, SQLite, and Microsoft SQL Server. These builders are independent of any particular database

Aura for PHP 424 Dec 12, 2022
The query filter bundle allows you to filter data from QueryBuilder and the Database

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

Milad Ghofrani 0 Apr 8, 2022
A simple program to query mysql data and display the queried data in JSON format

A simple program to query mysql data and display the queried data in JSON format. The data displayed in JSON format will change and update as the data in your mysql database changes.

null 2 Mar 7, 2022