PHPLaravel。如何将多个数据存储在一个受保护的变量数组中并检索它
PHP Laravel. How to store multiple data in one protected variable array and retrieve it
我很困惑如何从受保护的变量数组中检索数据,我已经在该变量上存储了数据,但是当我使用它时,它 returns 为空。
protected $item_quantity = array();
protected $item_id_pallet_lib = array();
foreach ($itemsUsed as $item) {
$this->item_id_pallet_lib = $this->pallet_assembly_library
->where('status', '=', 0)
->where('item_id', '=', $item->item->id) ->pluck('item_id');
$this->item_quantity = $this->theoretical
->where('item_id', '=', $this->item_id_pallet_lib)
->pluck('quantity');
}
-------------这是我第一次尝试检索数据,但它失败了,它 returns 为 null 或我的理论 table- 什么都没有发生--------
foreach ($itemsUsed as $item) {
$this->theoretical
->where('item_id', '=', $this->item_id_pallet_lib)
->update(array('quantity' => $this->item_quantity));
}
您只需添加 []
,这样您就可以在 $this->item_id_pallet_lib
和 $this->item_quantity
的最后存储值,如下所示:
$this->item_id_pallet_lib[]
$this->item_quantity[]
如果不行请在下方留言。
我很困惑如何从受保护的变量数组中检索数据,我已经在该变量上存储了数据,但是当我使用它时,它 returns 为空。
protected $item_quantity = array();
protected $item_id_pallet_lib = array();
foreach ($itemsUsed as $item) {
$this->item_id_pallet_lib = $this->pallet_assembly_library
->where('status', '=', 0)
->where('item_id', '=', $item->item->id) ->pluck('item_id');
$this->item_quantity = $this->theoretical
->where('item_id', '=', $this->item_id_pallet_lib)
->pluck('quantity');
}
-------------这是我第一次尝试检索数据,但它失败了,它 returns 为 null 或我的理论 table- 什么都没有发生--------
foreach ($itemsUsed as $item) {
$this->theoretical
->where('item_id', '=', $this->item_id_pallet_lib)
->update(array('quantity' => $this->item_quantity));
}
您只需添加 []
,这样您就可以在 $this->item_id_pallet_lib
和 $this->item_quantity
的最后存储值,如下所示:
$this->item_id_pallet_lib[]
$this->item_quantity[]
如果不行请在下方留言。