Created
December 22, 2019 18:10
-
-
Save mstaack/b8562df5e43e0537c7fea86ff66d1f20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\Facades\DB; | |
use Illuminate\Support\ServiceProvider; | |
use Jenssegers\Mongodb\Connection; | |
use Jenssegers\Mongodb\Queue\MongoConnector; | |
class MongodbServiceProvider extends \Jenssegers\Mongodb\MongodbServiceProvider | |
{ | |
/** | |
* Register the service provider. | |
*/ | |
public function register() | |
{ | |
// Add database driver. | |
$this->app->resolving('db', function ($db) { | |
$db->extend('mongodb', function ($config, $name) { | |
$config['name'] = $name; | |
$connection = new Connection($config); | |
// show queries in clockwork | |
if ($this->app->environment('local')) { | |
$connection->enableQueryLog(); | |
} | |
return $connection; | |
}); | |
}); | |
// Add connector for queue support. | |
$this->app->resolving('queue', function ($queue) { | |
$queue->addConnector('mongodb', function () { | |
return new MongoConnector($this->app['db']); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment