Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

laravel access DB facade in config files

$
0
0

I would like to make a DB query within my config/session.phpUnfortunately it seems that the framework is not fully loaded when this file gets evaluated and I get

class DB does not exist

I have tried 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;})(),

Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>