use Illuminate\Support\Facades\Redirect; public function store(Request $request) { // Insert code to store the data in database return Redirect::back()->with('success', 'Data has been saved successfully.'); }
use Illuminate\Support\Facades\Redirect; public function index() { if (!auth()->check()) { return Redirect::route('login')->with('error', 'Please login to continue.'); } // Insert code to show the dashboard page }In this example, the Redirect facade is used to redirect the user to the login page if they are not authenticated. It also passes an error message to the redirected page. This facade is a part of the Illuminate\Support package in Laravel.