php - Why's the value returning null when the variable's being correctly changed according to the dd()?

I currently have 2 functions I'm working with. Originally, thefetchInventories()
function didn't require an argument because I'm fetching some query results I need to use which's happening inside the{-code-2}
function. But down the line, I needed to make sure the query knows what's the current page number so I have to pass$current_page
to thefetchInventories()
function.
My question is: How would I be able to send the$current_page
variable with the correct value? When Idd($current_page);
inside the{-code-2}
function, it correctly displays2
. But when I do the same thing inside thefetchInventories()
function, it returns null. I thought thatnull
value got replaced with the aforementioned correct value?
What am I doing wrong & how can I rectify this?
Here's thefetchInventories
function
private function fetchInventories($current_page) {
$information = $this->getInventoryWithInformation();
dd($current_page); // returning null here
return $this->model
->join('item', 'inventoryitem.InventoryItemID', '=', 'item.type')
->groupBy('inventoryitem.InventoryItemID')
->select("inventoryitem.InventoryItemID", "inventoryitem.Description")
->select($information['inventory'])
->paginate(28, ['*'], 'page', $current_page);
}
Here's thegetInventories
function
public function {-code-2} {
$current_page = null;
$inventories = $this->fetchInventories($current_page);
$inventoriesArray = $inventories->toArray();
$current_page = $inventoriesArray['current_page'];
// dd($current_page); // correctly displays 2
$this->fetchInventories($current_page);
return $inventoriesArray;
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: target class [commandmakecommand] does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.