I want to add new custom service provider to set session_lifetime. The value for it, I got it from database. For do this thing I create service provider. But after the service provider registered. I got and error like this : Undefined index: path
.
This is my new service provider code :
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Config;
use Illuminate\Support\Facades\DB;
class ParameterSettingServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
}
/**
* Register services.
*
* @return void
*/
public function register()
{
if (\Schema::hasTable('parameter_settings')) {
$settings = DB::table('parameter_settings')->first();
if ($settings) //checking if table is not empty
{
$config = array(
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => env('SESSION_LIFETIME', $settings->session_expired),
'expire_on_close' => true,
);
Config::set('session', $config);
}
}
}
}
And this is my config/app.php
to register the service provider :
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\ParameterSettingServiceProvider::class,
How to fix this error?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire