RouteCollection.php中的NotFoundHttpException行161:在laravel 5中
我知道这是关于堆栈溢出的非常常见的问题,我尝试了其中的一些,但它并不适用于我的场景。
我的CollectionController看起来像这样。
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
use AppHttpRequests;
use AppHttpControllersController;
use AppHttpMiddlewareRole;
use IlluminateSupportFacadesInput;
use AppUser;
use AppInvoice;
use Session;
use Validator;
    class CollectionController extends Controller
    {
        /**
         * Display a listing of the resource.
         *
         * @return Response
         */
      public function __construct(){
        $this->middleware('role:collector'); // replace 'collector' with whatever role you need.
    }
      public function getHome(){
          $empid= Auth::user()->empid;
          $invoice = Invoice::where('Status','=',1)->orderBy('Id', 'desc')->get();
        return View('collectionmodule/home')->with(array('invoices'=>$invoice));
     }
       public function getPayment(){
    dd('sssss');
             $id =$invoiceid;
             $invoice = Invoice::where('Id','=',$id)->payments()->comments()->get();
             return View('collectionmodule/payment')->with(array('invoice'=>$id));
     }
        }
我的这个班的路线如下
Route::controller('collection/home','CollectionController');
Route::controller('collection/payment','CollectionController');
我得到以下错误
NotFoundHttpException in RouteCollection.php line 161:
没有一条路线可以工作,任何人都可以帮助我
我尝试过
http://localhost:8000/collection/home/
and 
http://localhost:8000/collection/payment
谢谢
您只需定义一次路线:
Route::controller('collection','CollectionController');
然后,您可以转到您在控制器的函数名称中声明的路线。
例:
回家 。 该路线将收集/回家
获得付款 。 该路线将是收款/付款
那很简单
在隐式调用中
我应该只定义一次路线
Route::controller('collection','CollectionController');
所以现在在url collection / home中如果被解析,laravel会自动调用getHome()函数
我在laravel 5.4.10中得到了完全相同的异常消息,在浪费了大约2个小时后,我发现routes.php已经在5.3以后的版本中被删除,仅仅创建文件是不够的。 我们需要将文件包含在RouteServiceProvider.php文件内的“map”函数中。 在map函数内部添加下面这行代码解决了我的问题:
require app_path('Http/routes.php');
上一篇: NotFoundHttpException in RouteCollection.php line 161: in laravel 5
