Suppose a situation in which, I have to run a command php artisan foo:bar
. In my command I have something like this:
public function handle()
{
// Some Query to the database using 'pluck'
$valuesFromDatabase = ['aaa', 'bbb'];
dd($valuesFromDatabase);
}
The first time this will lead to ['aaa', 'bbb']
.
Okay, now after 5 minutes there are some changes on database and the command will be run and the result would be like this:
public function handle()
{
// Some Query to the database using 'pluck' (same query as last time)
$valuesFromDatabase = ['aaa', 'ccc', 'ddd'];
// Something I should do here.
dd($valuesFromDatabase);
}
After the second time the command runs, result will be ['aaa', 'ccc', 'ddd']
, BUT I want the result to be like this ['aaa', 'bbb', 'aaa', 'ccc', 'ddd']
.
What should I do to store the values from the first time of running the command, beside the second time of running the command and have the values from the last time running the command? I need a way other than database, and tried with session but it renews after running the command for the second time.