簡體   English   中英

Laravel 6.x 路由:未找到查詢結果

[英]Laravel 6.x route: no query results found

我遇到了一個神秘的錯誤。 我定義了一條路線如下:

Route::get("/customers/alla", "Customer\CustomerController@loadAllCustomers")->name("customers.all");

當我調用該函數時,出現以下錯誤: No query results for model [App\\Models\\Customer] alla

loadAllCustomers()我只返回test進行測試。 但什么都沒有出現。

如果我將 url 更改為/customers/all那么錯誤也會從alla更改為all

xDebug 不會在函數中觸發。

laravel 想在那里做什么?

我也清除了路由緩存,但它不會改變任何東西

我的“整個”routes.php 看起來像這樣:

Route::get("/customers", "Customer\CustomerController@index")->name("customer.index");
    Route::get("/customers/{id}", "Customer\CustomerController@show")->name("customer.show");
    Route::get("/customers/alla", "Customer\CustomerController@loadAllCustomers")->name("customers.all");
    Route::post("/customers/store", "Customer\CustomerController@store")->name("customer.save");
    Route::post("/customers/{id}", "Customer\CustomerController@update")->name("customer.update");
    Route::get("/customers/{id}/delete", "Customer\CustomerController@delete")->name("customer.delete");
    Route::post("/customers/{id}/loadCustomerContactPersons", "Customer\CustomerController@loadCustomerContactPersons")->name("customer.contactPerson.all");
    Route::post("/customers/{id}/contactPerson", "Customer\CustomerController@createContactPerson")->name("customer.contactPerson.create");
    Route::get("/customer/{id}/contactPerson/{contactPersonId}", "Customer\CustomerController@getContactPerson")->name("customer.contactPerson.get");
    Route::put("/customer/{id}/contactPerson/{contactPersonId}", "Customer\CustomerController@updateContactPerson")->name("customer.contactPerson.update");
    Route::post("/customers/{id}/loadCustomerAddresses", "Customer\CustomerController@loadCustomerAddresses")->name("customer.customerAddress.all");
    Route::post("/customers/{id}/CustomerPayment/save", "Customer\CustomerController@saveCustomerPayment")->name("customer.customerPayment.save");
    Route::post("/customers/{id}/customerAddress", "Customer\CustomerController@createCustomerAddress")->name("customer.customerAddress.create");
    Route::get("/customers/{id}/deleteCustomerAddress/{addressId}", "Customer\CustomerController@deleteCustomerAddress")->name("customer.customerAddress.delete");
    Route::get("/customers/{id}/deleteContactPerson/{contactPersonId}", "Customer\CustomerController@deleteContactPerson")->name("customer.contactPerson.delete");

您的前兩條路線具有相同的模式。 Laravel 的路由調度器啟動第一個匹配的路由,所以當你訪問/customers/alla ,它實際上啟動了/customers/{id}$id = "alla" 沒有客戶的 ID 等於"alla" ,對吧?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM