getConnectionResolver() public static method

Get the connection resolver instance.
public static getConnectionResolver ( ) : Illuminate\Database\ConnectionResolverInterface
return Illuminate\Database\ConnectionResolverInterface
 public static function instance()
 {
     if (!static::$factory) {
         $translator = new Translator('en');
         static::$factory = new \Illuminate\Validation\Factory($translator);
         static::$factory->setPresenceVerifier(new DatabasePresenceVerifier(Eloquent::getConnectionResolver()));
     }
     return static::$factory;
 }
Ejemplo n.º 2
0
 private function setConnectionResolver()
 {
     if ($this->checkTablesExists() && is_null(Model::getConnectionResolver())) {
         $res = new ConnectionResolver();
         DB::pretend(function ($db) use($res) {
             $res->addConnection(config('database.default'), $db);
             $res->setDefaultConnection(config('database.default'));
         });
         Model::setConnectionResolver($res);
     }
 }
Ejemplo n.º 3
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $config = (require __DIR__ . '/../config.php');
     $capsule = new Manager();
     $capsule->addConnection($config);
     $capsule->bootEloquent();
     Schema::setConnection($capsule->getConnection('default'));
     DB::setConnection($capsule->getConnection('default'));
     // run the migrations
     $migration_repo = new DatabaseMigrationRepository(Model::getConnectionResolver(), 'migrations');
     if (!$migration_repo->repositoryExists()) {
         $migration_repo->createRepository();
     }
     $migrator = new Migrator($migration_repo, Model::getConnectionResolver(), new Filesystem());
     $migrator->rollback();
     $migrator->run(__DIR__ . '/../../src/migrations');
     static::loadFixtures();
 }
Ejemplo n.º 4
0
 /**
  * Get a schema builder instance.
  *
  * @return \Illuminate\Database\ConnectionInterface
  */
 protected function db()
 {
     return Eloquent::getConnectionResolver()->connection();
 }
Ejemplo n.º 5
0
 /**
  * Get a schema builder instance.
  *
  * @return \Schema\Builder
  */
 protected function schema()
 {
     return Eloquent::getConnectionResolver()->connection()->getSchemaBuilder();
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Model::getConnectionResolver()->connection()->getSchemaBuilder()->drop((new Preference())->getQualifiedTableName());
 }
Ejemplo n.º 7
0
 /**
  * Get a database connection instance.
  *
  * @return \Illuminate\Database\Connection
  */
 protected function connection($connection = 'default')
 {
     return Model::getConnectionResolver()->connection($connection);
 }
Ejemplo n.º 8
0
 public function getConnection()
 {
     $pdo = Eloquent::getConnectionResolver()->connection()->getPdo();
     return $this->createDefaultDBConnection($pdo, ':memory:');
 }
 /** @test */
 public function it_should_generate_participant_select_string()
 {
     $method = self::getMethod('createSelectString');
     $thread = new Thread();
     $columns = ['name'];
     $select = $method->invokeArgs($thread, [$columns]);
     $this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.name) as name", $select);
     $columns = ['name', 'email'];
     $select = $method->invokeArgs($thread, [$columns]);
     $this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.name || ' ' || " . Eloquent::getConnectionResolver()->getTablePrefix() . "users.email) as name", $select);
 }