This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/DB.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2016-02-18 23:28:44 +00:00
<?php
/**
2016-02-25 16:06:29 +00:00
* Holds the alias class for the Illuminate database thing.
2016-02-18 23:28:44 +00:00
* @package Sakura
*/
namespace Sakura;
use Illuminate\Database\Capsule\Manager;
use Illuminate\Database\ConnectionResolver;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
2016-02-18 23:28:44 +00:00
/**
2016-02-25 16:06:29 +00:00
* The Illuminate (Laravel) database wrapper.
2016-02-18 23:28:44 +00:00
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
2016-02-25 16:06:29 +00:00
class DB extends Manager
2016-02-18 23:28:44 +00:00
{
2016-10-07 17:55:50 +00:00
/**
* Start the database module.
* @param array $details
*/
public static function connect($details)
{
$capsule = new static;
$capsule->addConnection($details);
$capsule->setAsGlobal();
}
2016-08-05 02:35:37 +00:00
/**
* Gets the migration repository (surprise surprise).
* @return DatabaseMigrationRepository
*/
public static function getMigrationRepository()
{
$resolver = new ConnectionResolver(['database' => self::connection()]);
$repository = new DatabaseMigrationRepository($resolver, 'migrations');
$repository->setSource('database');
return $repository;
}
2016-08-05 02:35:37 +00:00
/**
* Get the migration schema builder.
* @return \Illuminate\Database\Schema\Builder
*/
public static function getSchemaBuilder()
{
return self::connection()->getSchemaBuilder();
}
2016-02-18 23:28:44 +00:00
}