當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::getConnectionResolver方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::getConnectionResolver方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::getConnectionResolver方法的具體用法?PHP Model::getConnectionResolver怎麽用?PHP Model::getConnectionResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::getConnectionResolver方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: instance

 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;
 }
開發者ID:silvertipsoftware,項目名稱:laravel-test-helpers,代碼行數:9,代碼來源:ValidatorHelper.php

示例2: setConnectionResolver

 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);
     }
 }
開發者ID:jooorooo,項目名稱:multi-language,代碼行數:11,代碼來源:Manager.php

示例3: setUpBeforeClass

 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();
 }
開發者ID:dadleyy,項目名稱:lvpress,代碼行數:19,代碼來源:TestCase.php

示例4: db

 /**
  * Get a schema builder instance.
  *
  * @return \Illuminate\Database\ConnectionInterface
  */
 protected function db()
 {
     return Eloquent::getConnectionResolver()->connection();
 }
開發者ID:JosephSilber,項目名稱:sqlite-unique-test,代碼行數:9,代碼來源:TestCase.php

示例5: schema

 /**
  * Get a schema builder instance.
  *
  * @return \Schema\Builder
  */
 protected function schema()
 {
     return Eloquent::getConnectionResolver()->connection()->getSchemaBuilder();
 }
開發者ID:Gummibeer,項目名稱:bouncer,代碼行數:9,代碼來源:BaseTestCase.php

示例6: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Model::getConnectionResolver()->connection()->getSchemaBuilder()->drop((new Preference())->getQualifiedTableName());
 }
開發者ID:klaude,項目名稱:eloquent-preferences,代碼行數:9,代碼來源:2015_12_20_000000_create_model_preferences_table.php

示例7: connection

 /**
  * Get a database connection instance.
  *
  * @return \Illuminate\Database\Connection
  */
 protected function connection($connection = 'default')
 {
     return Model::getConnectionResolver()->connection($connection);
 }
開發者ID:laraplus,項目名稱:translatable,代碼行數:9,代碼來源:IntegrationTestCase.php

示例8: getConnection

 public function getConnection()
 {
     $pdo = Eloquent::getConnectionResolver()->connection()->getPdo();
     return $this->createDefaultDBConnection($pdo, ':memory:');
 }
開發者ID:Busuu,項目名稱:slim-test-helpers,代碼行數:5,代碼來源:WebDbTestCase.php

示例9: it_should_generate_participant_select_string

 /** @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);
 }
開發者ID:elegantdevelopment,項目名稱:laravel-messenger,代碼行數:12,代碼來源:EloquentThreadTest.php


注:本文中的Illuminate\Database\Eloquent\Model::getConnectionResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。