<?php

namespace App\Console\Commands\Report;

class ReportPendSingular extends \App\Console\Commands\BaseCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'report-pend:singular';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Queue up the report for the notification pipeline';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $max = 2;

        $pipe = [];

        $base = base_path();
            
        for ($i = 0; $i < $max; ++$i) {
            $pipe[$i] = popen("php $base/artisan report-pend:singular-thread --as-max=$max --as-mod=$i", 'w');
        }
        
        for ($i = 0; $i < $max; ++$i) {
            pclose($pipe[$i]);
        }

        return 0;
    }
}