Php 为什么赢了';我的成功信息是';来自控制器的信息是否显示在视图中?
我想知道为什么来自控制器(Php 为什么赢了';我的成功信息是';来自控制器的信息是否显示在视图中?,php,laravel,debugging,bootstrap-4,Php,Laravel,Debugging,Bootstrap 4,我想知道为什么来自控制器(PostsController.php)的引导成功消息不会出现在视图(messages.blade.php)中 我看到Bootsrap成功的绿色横幅即将出现,但消息本身却没有。原因可能是什么 下面是messages.blade.php: @if(count($errors) > 0) @foreach($errors->all() as $error) <div class="alert alert-danger">
PostsController.php
)的引导成功消息不会出现在视图(messages.blade.php
)中
我看到Bootsrap成功的绿色横幅即将出现,但消息本身却没有。原因可能是什么
下面是messages.blade.php
:
@if(count($errors) > 0)
@foreach($errors->all() as $error)
<div class="alert alert-danger">
{{$error}}
</div>
@endforeach
@endif
@if(session('success'))
<div class="alert alert-success">
{{session('session')}}
</div>
@endif
@if(session('error'))
<div class="alert alert-danger">
{{session('error')}}
</div>
@endif
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'body' => 'required'
]);
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->save();
return redirect('/posts')->with('success', 'Post Created');
}
我想你想要
session('success')
在div里面?我觉得自己像个白痴。。。。非常感谢。我不敢相信我花了2个多小时在一个简单的bug上,有时让我怀疑自己:(.我们都去过那里
@if(session('success'))
...
{{session('session')}}
...
@endif