我想在config / session.php中进行数据库查询 不幸的是,当这个文件被评估并且我得到
时,框架似乎没有完全加载class DB does not exist
我尝试过DB :: and app() - > make(' db'):
'lifetime' => (function() {
$url = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$url = str_replace('www.', '', $url);
$parts = parse_url($url);
$host = isset($parts['host']) ? $parts['host'] : $parts['path'];
$campaign = app()->make('db')->table('campaigns')->where('url', $host)
->orWhere('url', 'like', $host.'%')
->orWhere('url', 'like', '%'.$host.'%')->first();
if($campaign && $campaign->session_lifetime)
return $campaign->session_liftetime;
else
return 24 * 60;
})(),
答案 0 :(得分:0)
加载配置文件时无法使用Facades。