Created
April 2, 2020 06:51
-
-
Save mstaack/3cf6c874c53979ec6cb26a592df13d7d to your computer and use it in GitHub Desktop.
This file contains 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 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