NotFoundHttpException in RouteCollection.php line 161: in laravel 5
I know this is very common question on stack overflow I tried few of them but its not working in my scenario .
My CollectionController looks like this .
<?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));
}
}
My Routes for this Class is as follow
Route::controller('collection/home','CollectionController');
Route::controller('collection/payment','CollectionController');
I am getting following error
NotFoundHttpException in RouteCollection.php line 161:
None of the routes are working can any one help me out
I tried with
http://localhost:8000/collection/home/
and
http://localhost:8000/collection/payment
Thanks
You have to define only one time the route:
Route::controller('collection','CollectionController');
And then you can go to the routes you declare in functions name of the controller.
Example:
get Home . The route will be collection/home
get Payments . The route will be collection/payments
Well It was pretty simple
In Implicit call
I should define the route only once
Route::controller('collection','CollectionController');
so now in url collection/home if being parsed then laravel will automatically call getHome() function
I was getting the exact same exception message in laravel 5.4.10 and after wasting around 2 hours I found out that routes.php has been removed in 5.3 onward versions and just creating file is not enough. We need to include file in RouteServiceProvider.php file inside "map" function. Adding below line inside map function resolved the issue for me :
require app_path('Http/routes.php');
链接地址: http://www.djcxy.com/p/88818.html
上一篇: 他们有关系吗?
下一篇: RouteCollection.php中的NotFoundHttpException行161:在laravel 5中