本文整理匯總了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;
}
示例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);
}
}
示例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();
}
示例4: db
/**
* Get a schema builder instance.
*
* @return \Illuminate\Database\ConnectionInterface
*/
protected function db()
{
return Eloquent::getConnectionResolver()->connection();
}
示例5: schema
/**
* Get a schema builder instance.
*
* @return \Schema\Builder
*/
protected function schema()
{
return Eloquent::getConnectionResolver()->connection()->getSchemaBuilder();
}
示例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);
}
示例8: getConnection
public function getConnection()
{
$pdo = Eloquent::getConnectionResolver()->connection()->getPdo();
return $this->createDefaultDBConnection($pdo, ':memory:');
}
示例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);
}