Reputation: 4896
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 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));
}
}
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
Upvotes: 11
Views: 59681
Reputation: 309
Check The Name Of The route,
whether it is capital or small.
Example-> If Folder name is Testing and view name is contact.
If You Write -> localhost/testing/contact, then it is an error because folder name i.e Testing and you have written small t i.e testing.
So you have to write -> localhost/Testing/contact.
And error is solved.
Upvotes: 0
Reputation: 46469
This is the most common exception.
NotFoundHttpException in RouteCollection.php
And it is quite easy to understand. You can dupe it if you misspell the route name.
It may be aricles
instead of articles
and things like that.
Try
php artisan route:list
And check if all the route names are OK.
Upvotes: 1
Reputation: 311
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');
Upvotes: 1
Reputation: 1657
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:
getHome. The route will be collection/home
getPayments. The route will be collection/payments
Upvotes: 5
Reputation: 4896
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
Upvotes: 1