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

前端之家收集整理的这篇文章主要介绍了RouteCollection.php第161行中的NotFoundHttpException:在laravel 5中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这是关于堆栈溢出的非常常见的问题我尝试了很少但它在我的场景中不起作用.

我的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));

     }




        }

我的这个班级的路线如下

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');

然后,您可以转到您在控制器的函数名称中声明的路径.

例:

回家.路线将是收集/回家

getPayments.该路线将是收款/付款

猜你在找的Laravel相关文章