diff options
author | Mateja <mail@matejamaric.com> | 2020-11-08 12:55:49 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-11-08 12:55:49 +0100 |
commit | d5691453f708ff5a288daeec21a00a19e888ca40 (patch) | |
tree | ac094dbf7a2e50c1fb131e93454b627d9f0e6d09 /app/Http | |
parent | b74cd28337d9774e37e0dbc8e541ea9026c6d7f7 (diff) | |
download | yota-laravel-d5691453f708ff5a288daeec21a00a19e888ca40.tar.gz yota-laravel-d5691453f708ff5a288daeec21a00a19e888ca40.zip |
Go back to previous news page...
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/NewsController.php | 8 |
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'))); } /** |