flash('success', 'This is a session flash success notification!'); return redirect()->back(); } /** * Test AJAX success notification. * * @return \Illuminate\Http\JsonResponse */ public function testAjaxSuccess() { return response()->json([ 'success' => true, 'message' => 'This is an AJAX success notification!' ]); } /** * Test AJAX error notification. * * @return \Illuminate\Http\JsonResponse */ public function testAjaxError() { return response()->json([ 'success' => false, 'flash' => [ 'type' => 'error', 'message' => 'This is an AJAX error notification!' ] ], 422); } }