不支持的操作数类型:array + App\StockOut Laravel

Unsupported operand types: array + App\StockOut Laravel

我想问问为什么当我尝试另一种情况时我的查询不起作用,我有这样的查询:

$getData = StockOut::select("*",
        StockOut::raw('group_concat(stock_outs.id_stock_out) as id_stock_outs'),
    )
    ->with(['stock_ins' => function ($query) {
        $query->select('id_stock_in', 'stock_in_id_type')
        ->with(['type_of_items' => function ($query) {
            $query->select('id_type_item', 'type_id_item', 'code_type_of_item', 'type_of_item');
        }]);
    }])
    ->groupBy('stock_outs.stock_out_id_stock_in')
    ->get()
    ->groupBy('stock_ins.stock_in_id_type')->map(function ($group) {
        return [
            'id_stock_ins' => $group->pluck('stock_ins.id_stock_in')->join(','),
            'id_stock_outs' => $group->pluck('id_stock_outs')->join(',')
        ] + $group->first();
    })->values();

我有这样的错误:

message: "Unsupported operand types: array + App\StockOut"

在 StockOut 模型中:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class StockOut extends Model
{
    protected $primaryKey = "id_stock_out";

    protected $fillable = [
        'stock_out_id_location', 'stock_out_id_stock_in', 'date_of_stock_out', 'quantity', 'description', 'created_by', 'edited_by'
    ];

    public function locations()
    {
        return $this->belongsTo('App\Location', 'stock_out_id_location');
    }

    public function stock_ins()
    {
        return $this->belongsTo('App\StockIn', 'stock_out_id_stock_in');
    } 
}

我现在真的不明白我的错误,因为当我在另一个项目中尝试我的查询时没有错误发生,我希望有人能帮助我指导我解决我的问题,谢谢你。

检查 $group 的值。它必须是数组类型才能使 + 运算符起作用。 目前你可能正在做

[/* ... */] + <an eloquent model>

这会给你那个错误