Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么赢了';我的成功信息是';来自控制器的信息是否显示在视图中?_Php_Laravel_Debugging_Bootstrap 4 - Fatal编程技术网

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