Laravel Framework 7.25.0
PHP 7.2 on LARAGON
我不确定它是否与此有关,但我认为这可能与我的路由有关,我可能在说胡话。
没有显示任何闪现消息,我只能通过将其设置为Session :: put,检索视图中的消息,然后删除它来显示消息。
Session::put('success', 'example');
return redirect()->route('example', array('id_example' => 'example'));
当我在前台使用with、withErrors、flash时,总是返回null。
return redirect()->route('example', array('id_example' => 'example'))->with('success', 'Text');
or
return redirect()->back()->withErrors( ['example'] );
or
Session::flash('success', 'example');
在我的视图中,我尝试了几种方式,它们的结果都相同。只有在我手动使用 Session::put 存储返回消息时才不同。
@if (Session::has('error'))
@if ($errors->any())
@if (Session::has('success'))
@if (session()->has('success'))
这是我在路由上使用的模型。
Route::namespace('Front')->group(function(){
# Homepage
Route::get('/', 'ExampleFrontController@Home')->name('home');
})
Route::namespace('Admin')->group(function(){
# Login
Route::get('/admin/login', 'ExampleAdminController@Index')->name('admin.login');
})
我使用Session::put没有问题,但我的表单请求规则返回的值也未显示,这给我造成了问题。