I have a problem with redirect()->back()when not HTTP_REFERER.
Usually when I open my URL with an identifier as a parameter to show a specific datarow:
http://my-domain/module/ID
If the specified IDdoes not exist or the current user having loggedin does not have permission to open it, I do
if (!$this->checkPermission($id)) {
return redirect()->back()->withError('message');
}
But when I change the address field of the browsers and load the invalid one ID, then there is no HTTP_REFERERset and it redirect()->back()redirects me to my last loaded JavaScript for_this_view.js(and shows it), added to view the following:
app.blade.php
<!DOCTYPE html>
<html lang="de">
<head>
@section('head')
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{!! HTML::style('assets/jquery-ui/jquery-ui.min.css?ver=1.11.4') !!}
@show
</head>
<body>
@yield('content')
</body>
</html>
show.blade.php
@extends('app')
@section('head')
@parent
{!! HTML::script('for_this_view.js') !!}
@stop
@section('content')
<!-- display datarow -->
@stop
redirect()->back()?
URL- , laravel ? ? , - .
.
UPDATE
, , ...
JavaScript, .
, , JavaScript , Blade. /config/view.php , for_this_view_js.blade.php. for_this_view.js routes.php.
- :
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(public_path())
) as $path)
{
if ($path->isFile()
&& ends_with($path->getFilename(), 'js.blade.php'))
{
Route::get('url_to_javascript.js', function() {
$contents = View::make('for_this_view_js(.blade.php)');
$response = Response::make($contents);
$response->header('Content-Type', 'application/javascript');
return $response;
});
}
}