private function getExceptionData($exception) { $data = []; $data['host'] = Request::server('HTTP_HOST'); $data['method'] = Request::method(); $data['fullUrl'] = Request::fullUrl(); if (php_sapi_name() === 'cli') { $data['host'] = parse_url(config('app.url'), PHP_URL_HOST); $data['method'] = 'CLI'; } $data['exception'] = $exception->getMessage(); $data['error'] = $exception->getTraceAsString(); $data['line'] = $exception->getLine(); $data['file'] = $exception->getFile(); $data['class'] = get_class($exception); $data['storage'] = array('SERVER' => Request::server(), 'GET' => Request::query(), 'POST' => $_POST, 'FILE' => Request::file(), 'OLD' => Request::hasSession() ? Request::old() : [], 'COOKIE' => Request::cookie(), 'SESSION' => Request::hasSession() ? Session::all() : [], 'HEADERS' => Request::header()); $data['storage'] = array_filter($data['storage']); $count = $this->config['count']; $data['exegutor'] = []; $data['file_lines'] = []; $file = new SplFileObject($data['file']); for ($i = -1 * abs($count); $i <= abs($count); $i++) { list($line, $exegutorLine) = $this->getLineInfo($file, $data['line'], $i); $data['exegutor'][] = $exegutorLine; $data['file_lines'][$data['line'] + $i] = $line; } // to make Symfony exception more readable if ($data['class'] == 'Symfony\\Component\\Debug\\Exception\\FatalErrorException') { preg_match("~^(.+)' in ~", $data['exception'], $matches); if (isset($matches[1])) { $data['exception'] = $matches[1]; } } return $data; }
private function composeTheme() { view()->composer(['_layout', '_shared._new_products', 'account'], function ($view) { $theme = 0 == Request::cookie('theme') ? 'blue' : 'pink'; $view->with('theme', $theme); }); }
public function anyIndex() { //获取路由传入的参数 //echo Route::input('name'); //获取配置信息 $value = config('app.timezone'); //var_dump($value); //获取请求输入 http://host-8/web/user?name=dfse 输出:dfse $name1 = Request::has('name') ? Request::get('name') : ''; //取得特定输入数据,若没有则取得默认值 $name2 = Request::input('name', '默认值'); $input = Request::all(); //所有的 $input = Request::input('products.0.name'); //重定向 //return redirect('login'); //获取cookie $value = Request::cookie('name'); //获取域名 $url = Request::root(); // echo $url; $data = ['url' => $url, 'name1' => $name1, 'name2' => $name2, 'value' => $value]; //响应视图 响应最常用的几个方法:make/view/json/download/redirectTo return response()->view('user.user', $data); }
private static function checkLaravelCookie() { $cv = Request::cookie('laravel-remember'); \Debugbar::error("laravel cookie: {$cv}"); $uc = UserCookie::where('cookie', '=', $cv)->get()->first(); if ($uc != null) { $user = User::where('id', '=', $uc->user_id)->get()->first(); Auth::login($user); } }
function get() { $url = '/'; Auth::logout(); UserCookie::where('cookie', '=', Request::cookie('laravel-remember'))->delete(); if (Config::get('punto-cms.c2go-login') === true) { $url = 'https://sso.communitytogo.com.au/logout'; if (Config::get('punto-cms.c2go-redirect-logout') !== null) { $url = Config::get('punto-cms.c2go-redirect-logout'); } } return Redirect::to($url)->withCookie(Cookie::forget('remember'))->withCookie(Cookie::forget('laravel-remember')); }