Papa Kent
Papa Kent

Reputation: 25

PHP Laravel. How to store multiple data in one protected variable array and retrieve it

im confused how to retrieve data from protected variable array, im already stored data on that variable but when i used it, it returns null.

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');

}

-------------this is my first attempt to retrieve data, but it fails and it returns null or nothing happens to my theoretical table---------

foreach ($itemsUsed as $item) {

 $this->theoretical
      ->where('item_id', '=', $this->item_id_pallet_lib)
      ->update(array('quantity' => $this->item_quantity));

}

Upvotes: 1

Views: 248

Answers (1)

Blues Clues
Blues Clues

Reputation: 1838

You just have to add [] so you can store value at the last of your $this->item_id_pallet_lib and $this->item_quantity like so:

$this->item_id_pallet_lib[]
$this->item_quantity[]

Please leave a comment below if it won't work.

Upvotes: 1

Related Questions