我有一个叫
PriceList
当我使用
::resource
路由功能,只有我通过时才有效
price/lists
作为第一个参数。
例如,如果我执行以下操作:
Route::resource('pricelists', 'PriceListsController');
然后在控制器中,我执行以下操作:
use App\PriceList;
class PriceListsController
{
public function show(PriceList $list)
{
dd($list);
}
}
如果我访问url:
/pricelists/1
,它给了我一个空的
价格表
:
PriceList {#802 â¼
#appends: array:4 [â¶]
#hidden: array:4 [â¶]
#with: array:1 [â¶]
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#withCount: []
#perPage: 15
+exists: false
+wasRecentlyCreated: false
#attributes: []
#original: []
#changes: []
#casts: []
#dates: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#visible: []
#fillable: []
#guarded: array:1 [â¶]
}
但是,如果我将资源更改为:
Route::resource('price/lists', 'PriceListsController');
并访问url:
/price/lists/1
,然后我得到
价格表
:
PriceList {#820 â¼
#appends: array:4 [â¶]
#hidden: array:4 [â¶]
#with: array:1 [â¶]
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:7 [â¶]
#original: array:7 [â¶]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: array:1 [â¶]
#touches: []
+timestamps: true
#visible: []
#fillable: []
#guarded: array:1 [â¶]
}
如何更改
价格/清单
到
pricelists
?
使现代化
我试过使用
Route::model
my中的函数
RouteServiceProvider
:
Route::model('pricelists', App\PriceList::class);