小编Aja*_*ana的帖子

从Laravel Eloquent集合中取消设置/删除关系对象

我通过以下方式获取Laravel Eloquent收藏夹:

$product = Product::query()->with(['merchant', 'picture'])->where('id', $id)->first();
Run Code Online (Sandbox Code Playgroud)

并得到的$product

Product {
  #casts: ...
  #dates: ...
  #connection: "mysql"
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:1 [
    "id" => 27
  ]
  #original: ...
  #changes: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:2 [
    "merchant" => Merchant {...}
    "picture" => Picture {...}
    }
  ]
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: []
  #guarded: ... …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent

3
推荐指数
1
解决办法
5002
查看次数

标签 统计

eloquent ×1

laravel ×1