本文作者:admin

Laravel 资源路由id与注入注意事项

admin 2022-08-04 08:13:58
Laravel 资源路由id与注入注意事项摘要: 例如路由命名web.php里是 product那你资源路由里use模型后Proudct $product这样才会返回结果$后的名字要和命名相同否则返回的是空。查询命名方法:php...
电信鸢尾卡
类型:免费包邮
特点:39元260G支持结转黄金速率
联通黑牛卡
类型:免费包邮
特点:29元135G全国流量+100分钟
移动金香卡
类型:免费包邮
特点:29元155G首月免月租
流量卡营业厅
全网营业厅超市
免费包邮,应有尽有

例如路由命名web.php里是 product

那你资源路由里use模型后Proudct $product这样才会返回结果$后的名字要和命名相同

否则返回的是空。

查询命名方法:php artisan route:list

 

例如红色部分必须相同

Route::resource(‘productcategory‘,’Admin\ProductCategoryController’);

public function edit(ProductCategory $productcategory)
{
    dd($productcategory);
}
  #table: "product_category"
  +timestamps: true
  #primaryKey: "cid"
  #guarded: []
  #fillable: []
  #connection: "mysql"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:12 []
  #original: array:12 []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  #hidden: []
  #visible: []


正规流量卡免费办理,长按二维码进入

阅读
分享