aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-11-08 12:55:49 +0100
committerMateja <mail@matejamaric.com>2020-11-08 12:55:49 +0100
commitd5691453f708ff5a288daeec21a00a19e888ca40 (patch)
treeac094dbf7a2e50c1fb131e93454b627d9f0e6d09 /app/Http/Controllers
parentb74cd28337d9774e37e0dbc8e541ea9026c6d7f7 (diff)
downloadyota-laravel-d5691453f708ff5a288daeec21a00a19e888ca40.tar.gz
yota-laravel-d5691453f708ff5a288daeec21a00a19e888ca40.zip
Go back to previous news page...
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r--app/Http/Controllers/NewsController.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php
index 8be535e..8ea2000 100644
--- a/app/Http/Controllers/NewsController.php
+++ b/app/Http/Controllers/NewsController.php
@@ -7,6 +7,8 @@ use function dd;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Redirect;
+use Illuminate\Support\Facades\Session;
+use Illuminate\Support\Facades\URL;
use App\Models\Post;
@@ -21,6 +23,7 @@ class NewsController extends Controller
{
$news = Post::orderBy('created_at', 'desc')->paginate(6);
+ Session::flash('prev-url', URL::full());
//$data = ['news' => $news];
//return view('pages.news')->with($data);
//return view('pages.news')->with('news', $news);
@@ -91,6 +94,7 @@ class NewsController extends Controller
public function edit($id)
{
$data = Post::findOrFail($id);
+ Session::keep('prev-url');
return view('pages.editpost', compact('data'));
}
@@ -126,8 +130,8 @@ class NewsController extends Controller
$post->text = $request->text;
$post->saveOrFail();
- return Redirect::route('news')->with('status', "Post edited.");
- } else return Redirect::route('news');
+ return Redirect::to(Session::get('prev-url', route('news')))->with('status', "Post edited.");
+ } else return Redirect::to(Session::get('prev-url', route('news')));
}
/**