拉拉维尔雄辩版本更改

问题描述 投票:0回答:1

checkhttps://github.com/hilal-najem3/composers.git forComposers.lock

我有以下代码:

$where = [ ['warehouse_id', $warehouse->id], ['product_id', $product->id], ['section_id', $sectionId] ]; $orWhere = [ ['to_warehouse_id', $warehouse->id], ['product_id', $product->id], ['section_id', $sectionId] ]; $transactions = InventoryTransaction::where($where)->orWhere($orWhere)->get();
SO查询来自

print_r(InventoryTransaction::where($where)->orWhere($orWhere)->toSql());


select*from `inventory_transactions`where((`warehouse_id`=?and `product_id`=?and `section_id`=?)or(`to_warehouse_id`=?and `product_id`=?and `section_id`=?))and `inventory_transactions`.`deleted_at`is null
我做了
composer update

,必须将上述更改为:

$transactions = InventoryTransaction::where($where)->get();
$t = InventoryTransaction::where($orWhere)->get();
$transactions = $transactions->merge($t);

so询问从
print_r(InventoryTransaction::where($where)->orWhere($orWhere)->toSql());

select * from `inventory_transactions` where ((`warehouse_id` = ? and `product_id` = ? and `section_id` = ?) or (`to_warehouse_id` = ? or `product_id` = ? or `section_id` = ?)) and `inventory_transactions`.`deleted_at` is null

或我将有重复的人,我不得不将作曲家恢复起来!! 我应该采取的措施使我的应用程序保持更新,就像在作曲家更新中一样,并保留上述代码。请注意,如果修复了很多地方,则需要更改一些地方。这样,我无法更新以将来的版本!!
    

您的问题主要是由于没有指定过多的过滤器关系,并且由于您不需要复制产品和仓库BC,因此您检查了相同的ID,因此您可以更明确地如此明确。

InventoryTransaction::query() ->where('product_id', $product->id) ->where('section_id', $sectionId) ->where(function (Builder $query) use ($warehouse) { $query->where('warehouse_id', $warehouse->id) ->orWhere('to_warehouse_id', $warehouse->id); }) ->get();
laravel eloquent laravel-11
1个回答
0
投票
在:

select * from `inventory_transactions` where `product_id` = ? and `section_id` = ? and (`warehouse_id` = ? or `to_warehouse_id` = ?) and `inventory_transactions`.`deleted_at` is null
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.