【问题标题】:Laravel - Eloquent merge collection with single itemLaravel - 单项的 Eloquent 合并集合
【发布时间】:2018-11-11 00:51:21
【问题描述】:

如何将 Eloquent 集合与单个项目合并?尝试合并会导致错误:

Call to a member function getKey() on boolean

【问题讨论】:

    标签: laravel collections merge eloquent


    【解决方案1】:

    您应该使用集合的push 方法:

    $collection = new Collection;
    $collection->push($item);
    

    【讨论】:

    • 我到处寻找这个愚蠢的问题,终于找到了答案,所以我添加了这个,希望能节省其他人的时间。
    猜你喜欢
    • 2019-10-13
    • 1970-01-01
    • 2017-04-12
    • 2019-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-29
    • 1970-01-01
    相关资源
    最近更新 更多