我知道這是堆棧溢出中非常常見的問題我嘗試了其中的幾個,但它在我的場景中不起作用。RouteFollection.php中的NotFoundHttpException行161:laravel 5
My 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/home','CollectionController @ index'); Route :: controller('collection/payment','CollectionController @ payment'); –
@LaljiNakum我得到了我的答案我正在使用隱式的方式,所以我不得不指定一個這樣的路線 'Route :: controller('collection','CollectionController'); 「它的工作正常,順便說一句,你有沒有anyidea我將如何調用一個模型,有一對多的關係? – Vikram
嘿維克拉姆,如果你在這裏發佈你的答案以供將來參考。 –