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

53 lines
1.3 KiB
PHP
Raw Permalink 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-12-04 16:33:52 +00:00
use Illuminate\Database\Schema\Builder;
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
*/
2016-12-04 16:33:52 +00:00
public static function connect(array $details): void
2016-10-07 17:55:50 +00:00
{
$capsule = new static;
$capsule->addConnection($details);
$capsule->setAsGlobal();
}
2016-08-05 02:35:37 +00:00
/**
* Gets the migration repository (surprise surprise).
* @return DatabaseMigrationRepository
*/
2016-12-04 16:33:52 +00:00
public static function getMigrationRepository(): DatabaseMigrationRepository
{
$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.
2016-12-04 16:33:52 +00:00
* @return Builder
2016-08-05 02:35:37 +00:00
*/
2016-12-04 16:33:52 +00:00
public static function getSchemaBuilder(): Builder
{
return self::connection()->getSchemaBuilder();
}
2016-02-18 23:28:44 +00:00
}