小编raa*_*man的帖子

将新属性引入laravel集合对象

我需要在以下laravel集合对象中引入一个新的字段/属性.正如您所看到的,我有像project,bidamount,awarddate等字段....我想为集合中的每个项目添加另一个新的"付费"字段.我怎样才能做到这一点?

该集合是hasMany关系的结果.

Collection {#233 ?
#items: array:20 [?
0 => Project {#234 ?
  #table: "projects"
  #attributes: array:11 [?]
  #connection: null
  #primaryKey: "id"
  #perPage: 15
  +incrementing: true
  +timestamps: true
  #original: array:11 [?
    "id" => "15348"
    "project" => "Construction of blah blah blah"
    "bidamount" => "36830525"
    "awarddate" => "2012-08-15"
    "completedate" => "2013-12-31"
    "levyamount" => "55246"
    "fkcdb" => "1656"
    "fkfile" => "0"
    "fkclient" => "0"
    "created_at" => "0000-00-00 00:00:00"
    "updated_at" => "0000-00-00 00:00:00"
  ]
  #relations: []
  #hidden: []
  #visible: []
  #appends: []
  #fillable: …
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent

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

标签 统计

eloquent ×1

laravel ×1

php ×1