RouteCollection.php中的NotFoundHttpException(第179行)

时间:2017-06-14 22:21:39

标签: php laravel

我在网络应用中遇到的问题是,当用户输入状态并按“添加状态”而不是保存状态时,我会收到以下错误:NotFoundHttpException in RouteCollection.php (line 179)。 我在网上做了一些研究并查看了类似的问题,并尝试改变它,但我仍然遇到了同样的问题。

这是我的控制器类

<?php

namespace App\Http\Controllers;

use Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $r)
    {
        if(Request::has('status-text'))
        {
            $text = e(Request::get('status-text'));

            $userStatus = new Status();
            $userStatus->status_text = $text;
            $userStatus->user_id = Auth::user()->id;
            $userStatus->save();
            Flash::success('Your status has been posted');
            return redirect(route('home'));

                }


        return view('home');
    }
}

这是我的web.php类

<?php
    return view('welcome');
});

Auth::routes();

Route::any('/home', ['as'=> 'home','uses'=>'HomeController@index']);

enter image description here

这是我要回复的错误图片:

enter image description here

1 个答案:

答案 0 :(得分:0)

首先,您可以在routes / web.php文件中返回view()。你需要做的就是让你的web.php像这样:

> models.py

应该解决你的问题。

相关问题