Package Data | |
---|---|
Maintainer Username: | acacha |
Maintainer Contact: | sergiturbadenas@gmail.com (Sergi Tur Badenas) |
Package Create Date: | 2016-11-11 |
Package Last Update: | 2016-11-11 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-04 03:21:26 |
Package Statistics | |
---|---|
Total Downloads: | 392 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel 5 packages to support multiple database connections for historical data (One period -> One database connection)
Via Composer
$ composer require acacha/periods
Add PeriodsServiceProvider service provider to config/app.php file:
...
/*
* Package Service Providers...
*/
Acacha\Periods\Providers\PeriodsServiceProvider::class,
...
Publish files with:
php artisan vendor:publish --tag=acacha_periods
Register Laravel Middleware on class App\Http\Kernel.php at the end of web middleware group:
...
protected $middlewareGroups = [
'web' => [
...
\Acacha\Periods\Middleware\Periods::class
],
...
Customize your config. First adapt to your needs fil config/periods.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:
...
'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' => '',
],
...
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email sergiturbadenas@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.