I'm trying to take existing/working code from a laravel controller and create an array of customers from an existing query function in that controller.
Here is the controller code portion that works:
CONTROLLER
$d->createdAt = new \DateTime($d->created_at);
$deadline = Carbon::now()->subMonths(2);
if($d->nextDate <= $now && $d->createdAt > $deadline && $d->status != 'exempt'){
$d->status = 'priority';
}
That block of code works by taking an existing query in the controller, querying the 'created_at' column in the database, and if it's within the last 6 months it applys a status of 'priority' which is used as a css class to highlight.
That works perfectly.
Now, I want to take any affected customer from that query ($d->custNum) with a status of 'priority', put it in an array and then pass the array to my function called findActive in my activeCust.php file
activeCust.php
public function findActive($custNum){
$sql ="
SELECT c.customer
FROM customers C
WHERE c.customer NOT IN ($custNum)
";
}
Basically, after that code block in the controller, I want to create an array of all returned customer numbers (i.e. the status of 'priority') and pass that array to the function so that I can say "Run this findActive query on any customer that isn't in this array".
The idea here is extending the working code into a new file that does the same highlighting but works off of different logic. I'm just not sure the best way to create the array so that I can pass it into the function properly.
How can I create an array from the returned values in the controller code block and use the array for my 'NOT IN' in the function query in activeCust.php?