Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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
RouteCollection.php第161行中的NotFoundHttpException:在laravel 5中_Php_Laravel 5_Laravel 5.2 - Fatal编程技术网

RouteCollection.php第161行中的NotFoundHttpException:在laravel 5中

RouteCollection.php第161行中的NotFoundHttpException:在laravel 5中,php,laravel-5,laravel-5.2,Php,Laravel 5,Laravel 5.2,我知道这是关于堆栈溢出的一个非常常见的问题,我尝试了其中的几个,但在我的场景中不起作用 我的CollectionController看起来像这样 <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use App\Http\Requests; use App\Http\Controllers\Controller; use App\

我知道这是关于堆栈溢出的一个非常常见的问题,我尝试了其中的几个,但在我的场景中不起作用

我的CollectionController看起来像这样

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Middleware\Role;
use Illuminate\Support\Facades\Input;
use App\User;
use App\Invoice;
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));

     }




        }
我得到以下错误

NotFoundHttpException in RouteCollection.php line 161:
所有的路线都没用,有人能帮我吗

我试过了

http://localhost:8000/collection/home/

and 

http://localhost:8000/collection/payment

谢谢

很简单

隐式调用

我应该只定义一次路线

Route::controller('collection','CollectionController');
所以现在在url集合/主页中,如果被解析,那么laravel将自动调用
getHome()函数

您只需定义一次路由:

Route::controller('collection','CollectionController');
然后,您可以转到在控制器的函数名中声明的路由

例如:

回家。路线为收集/回家


获得付款。路线将是收款/付款

我在laravel 5.4.10中收到了完全相同的异常消息,在浪费了大约2个小时后,我发现routes.php在5.3以后的版本中已被删除,仅创建文件是不够的。我们需要将RouteServiceProvider.php文件包含在“map”函数中。 在映射函数中添加以下行为我解决了问题:

require app_path('Http/routes.php');

这是最常见的例外

NotFoundHttpException in RouteCollection.php
这很容易理解。如果您拼错了路线名称,您可以复制它。 它可能是
aricles
而不是
articles
之类的东西

试一试


并检查所有路由名称是否正常。

检查路由名称

无论是资本还是小规模

示例->如果文件夹名为Testing,视图名为contact

如果您编写->localhost/testing/contact,那么这是一个错误,因为文件夹名为i.e testing,您编写了小t.e testing

因此,您必须编写->localhost/Testing/contact


并解决了误差

我认为您需要在路由中传递方法名。如下所示:路由::控制器('collection/home','CollectionController@index'); 路线::控制器('收款/付款','CollectionController@payment');@LaljiNakum我得到了我的答案,我使用隐式方法,所以我必须只分配一条路径,像这样
route::controller('collection','CollectionController')现在可以正常工作了,顺便问一下,你知道我将如何称呼一对多关系的模型吗?嘿,Vikram,最好你在这里发布你的答案,以供将来参考。@Bharageleda是的,我现在就发布它。请看一下这个答案,它可能会有所帮助
NotFoundHttpException in RouteCollection.php
php artisan route:list