periods
![Software License][ico-license]
![Coverage Status][ico-scrutinizer]
![Total Downloads][ico-downloads], (*1)
Laravel 5 packages to support multiple database connections for
historical data (One period -> One database connection), (*2)
Install
Via Composer, (*3)
``` bash
$ composer require acacha/periods, (*4)
Add **PeriodsServiceProvider** service provider to **config/app.php** file:
```php
...
/*
* Package Service Providers...
*/
Acacha\Periods\Providers\PeriodsServiceProvider::class,
...
Publish files with:, (*5)
php artisan vendor:publish --tag=acacha_periods
Usage
Register Laravel Middleware on class App\Http\Kernel.php at the end
of web middleware group:, (*6)
``` php
...
protected $middlewareGroups = [
'web' => [
...
\Acacha\Periods\Middleware\Periods::class
],
..., (*7)
Customize your config. First adapt to your needs fil **config/periods.php**:
```php
<?php
return [
/*
|--------------------------------------------------------------------------
| Session variable name for periods
|--------------------------------------------------------------------------
|
| This value is the name of the session vairable that storages desired period.
*/
'session_variable' => 'ACACHA_PERIOD',
/*
|--------------------------------------------------------------------------
| Valid period values and related database connections
|--------------------------------------------------------------------------
|
| This value is an array that stores valid period values and his related
| database connections.
*/
'periods' => [
'2016-17' => env('DB_CONNECTION', 'mysql'),
'2015-16' => env('DB_CONNECTION', 'mysql') . '_1516',
'2014-15' => env('DB_CONNECTION', 'mysql') . '_1415',
],
];
By sure that you have multiple database connections
(default sqlite, sqlite_1516, sqlite_1415...) at config file config/database.php:, (*8)
...
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'sqlite_1516' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database1516.sqlite')),
'prefix' => '',
],
'sqlite_1415' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database1415.sqlite')),
'prefix' => '',
],
...
Change log
Please see CHANGELOG for more information what has changed recently., (*9)
Testing
bash
$ composer test
, (*10)
Contributing
Please see CONTRIBUTING and CONDUCT for details., (*11)
Security
If you discover any security related issues, please email sergiturbadenas@gmail.com instead of using the issue tracker., (*12)
Credits
License
The MIT License (MIT). Please see License File for more information., (*13)