Execute the job.

@return void
@throws \Throwable
674
protected function job(): void
    {
        CorporationDivision::where('corporation_id', $this->getCorporationId())->get()
            ->each(function ($division) {

                // retrieve last known entry for the current division and active corporation
                $last_known_entry = CorporationWalletJournal::where('corporation_id', $this->getCorporationId())
                                                            ->where('division', $division->division)
                                                            ->orderBy('date', 'desc')
                                                            ->first();

                $this->last_known_entry_id = is_null($last_known_entry) ? 0 : $last_known_entry->id;

                // Perform a journal walk backwards to get all of the
                // entries as far back as possible. When the response from
                // ESI is empty, we can assume we have everything.
                while (true) {

                    $journal = $this->retrieve([
                        'corporation_id' => $this->getCorporationId(),
                        'division'       => $division->division,
                    ]);

                    if ($journal->isCachedLoad()) return;

                    $entries = collect($journal);

                    // If we have no more entries, break the loop.
                    if ($entries->count() === 0)
                        break;

                    $entries->chunk(1000)->each(function ($chunk) use ($division) {

                        // if we've reached the last known entry - abort the process
                        if ($this->at_last_entry)
                            return false;

                        // if we have reached the last known entry, exclude all entries which are lower or equal to the
                        // last known entry and flag the reached status.
                        if ($chunk->where('id', $this->last_known_entry_id)->isNotEmpty()) {
                            $chunk = $chunk->where('id', '>', $this->last_known_entry_id);

                            $this->at_last_entry = true;
                        }

                        $records = $chunk->map(function ($entry, $key) use ($division) {

                            return [
                                'corporation_id'  => $this->getCorporationId(),
                                'division'        => $division->division,
                                'id'              => $entry->id,
                                'date'            => carbon($entry->date),
                                'ref_type'        => $entry->ref_type,
                                'first_party_id'  => $entry->first_party_id ?? null,
                                'second_party_id' => $entry->second_party_id ?? null,
                                'amount'          => $entry->amount ?? null,
                                'balance'         => $entry->balance ?? null,
                                'reason'          => $entry->reason ?? null,
                                'tax_receiver_id' => $entry->tax_receiver_id ?? null,
                                'tax'             => $entry->tax ?? null,
                                // introduced in v4
                                'description'     => $entry->description,
                                'context_id'      => $entry->context_id ?? null,
                                'context_id_type' => $entry->context_id_type ?? null,
                                'created_at'      => carbon(),
                                'updated_at'      => carbon(),
                            ];
                        });

                        CorporationWalletJournal::insertIgnore($records->toArray());
                    });

                    // in case the last known entry has been reached or we non longer have pages, terminate the job.
                    if (! $this->nextPage($journal->pages) || $this->at_last_entry)
                        break;
                }

                // Reset the page for the next wallet division.
                $this->page = 1;

                // Reset the last known entry for the next wallet division.
                $this->last_known_entry_id = 0;

                // Reset the last known entry status for the next wallet division.
                $this->at_last_entry = false;
            });
    }
1290667
public function handle()
    {
        try {
            $this->filesystem->overwrite(
                $path = database_path('seeds/' . config('AdminUserSeeder', 'AdminUserSeeder.php')),
                $this->compiler->compile(
                    $this->filesystem->get($this->getStubPath()),
                    [
                        "USER_NAME" => $this->username(),
                        "USER_EMAIL" => $this->email(),
                    ]
                )
            );
            $this->info('File ' . $path . ' created');
        } catch (\Exception $e) {
            print_r($e->getMessage());
        }
    }
1085448
public function handle()
	{
		$counter = JobsFacade::run();

		if ($counter === false) {
			$this->error('Job executor needs to cool down for '.(JobsFacade::remainingCoolDown() * 60)
                .' seconds! No jobs executed.');
		} else {
			$this->info('Done. Jobs executed: '.$counter.'/'.JobsFacade::count());
		}			
	}
848963
public function handle()
    {

        $connection = $this->option("connection") ? $this->option("connection") : config("es.default");

        $indices = $this->es->connection($connection)->raw()->cat()->indices();

        if (is_array($indices)) {
            $indices = $this->getIndicesFromArrayResponse($indices);
        } else {
            $indices = $this->getIndicesFromStringResponse($indices);
        }

        if (count($indices)) {
            $this->table($this->headers, $indices);
        } else {
            $this->warn('No indices found.');
        }

    }
437983
public function handle()
    {
        $this->module = $this->laravel['modules'];

        $name = $this->argument('module');

        if (!empty($name)) {
            $this->reset($name);

            return;
        }

        foreach ($this->module->getOrdered($this->option('direction')) as $module) {
            $this->line('Running for module: <info>' . $module->getName() . '</info>');

            $this->reset($module);
        }
    }
850465
public function handle()
	{
		$connection = $this->argument('connection') ?: $this->config->get('queue.default');
		$queue = $this->argument('queue') ?: $this->config->get('queue.connections.' . $connection  . '.queue');

		$this->info(sprintf('Clearing queue "%s" on "%s"', $queue, $connection));
		$cleared = $this->clearer->clear($connection, $queue);
		$this->info(sprintf('Cleared %d jobs', $cleared));
	}
1362326
public function handle()
    {
        $this->info('Generating optimized class loader');

        $this->laravel->configure('optimizer');

        $this->composer->dumpAutoloads('--no-dev --optimize');

        if ($this->option('force') || !env('APP_DEBUG')) {
            $this->info('Compiling common classes');

            $this->compileClasses();
        } else {
            $this->call('clear-compiled');
        }
    }
534937
public function handle()
    {
        $totalThreadCount = 0;
        $categories = Category::all();

        foreach ($categories as $category) {
            $this->info("Updating counts for {$category->title}...");

            foreach ($category->threads as $thread) {
                $totalThreadCount++;
                Stats::updateThread($thread);
            }

            Stats::updateCategory($category);
        }

        $this->info("Updated counts on {$categories->count()} categories and {$totalThreadCount} threads.");
    }
680479
public function execute()
	{
		$this->output = $this->output->getHelpOutput();
		$this->help();
		$this->output->render();
		return;
	}
831445
public function execute()
    {
        // sort jobs by priority
        $jobs = [];
        ksort($this->jobs);
        foreach ($this->jobs as $priority_jobs) {
            $jobs = array_merge($jobs, $priority_jobs);
        }

        /* @var $job Job */
        foreach ($jobs as $job) {
            $job->execute();
        }
    }
739907
public function handle()
    {
        $this->profile = $this->argument('profile');

        // check valid profile
        if (!Config::get('ntrust.profiles.' . $this->profile))
        {
            $this->error('Invalid profile. Please check profiles in config/ntrust.php');
            return;
        }

        $this->line(substr(__DIR__, 0, -8).'views');

        $this->laravel->view->addNamespace('ntrust', substr(__DIR__, 0, -15).'views');

        $rolesTable          = Config::get('ntrust.profiles.'. $this->profile .'.roles_table');
        $roleUserTable       = Config::get('ntrust.profiles.'. $this->profile .'.role_user_table');
        $permissionsTable    = Config::get('ntrust.profiles.'. $this->profile .'.permissions_table');
        $permissionRoleTable = Config::get('ntrust.profiles.'. $this->profile .'.permission_role_table');

        $this->line('');
        $this->info( "Tables: $rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable" );

        $message = "A migration that creates '$rolesTable', '$roleUserTable', '$permissionsTable', '$permissionRoleTable'".
            " tables will be created in database/migrations directory";

        $this->comment($message);
        $this->line('');

        if ($this->confirm("Proceed with the migration creation? [Yes|no]", "Yes")) {

            $this->line('');

            $this->info("Creating migration...");
            if ($this->createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable)) {

                $this->info("Migration successfully created!");
            } else {
                $this->error(
                    "Couldn't create migration.\n Check the write permissions".
                    " within the database/migrations directory."
                );
            }

            $this->line('');

        }
    }
791197
public function handle()
    {
        $this->showWelcomeMessage();
        $this->userSetup();
        $this->triggerPublish();
        $this->call('dashboard:fresh');
        $this->setupSeedStubs();
        $this->triggerMigrations();
        $this->createDefaultUser();
        $this->info('Setup is complete. Keep coding!');
    }
600948
public function handle()
    {
        $this->loadConfiguration();

        foreach ( $this->configurationData as $serviceData ) {
            $this->createdFiles = [];
            $this->createService($serviceData);
            $this->finalizeFile($serviceData->file);
        }

        $this->call('hc:routes');
        $this->call('hc:forms');
        $this->call('hc:admin-menu');
    }
388784
public function handle()
    {
        // Load Data
        $stats   = $this->logViewer->statsTable('en');

        $rows    = $stats->rows();
        $rows[]  = $this->tableSeparator();
        $rows[]  = $this->prepareFooter($stats);

        // Display Data
        $this->displayLogViewer();
        $this->table($stats->header(), $rows);
    }
966864
public function handle()
    {
        $target = $this->argument('target');
        $options = [
            'compress' => $this->option('compress'),
            'json' => $this->option('json'),
            'no-lib' => $this->option('no-lib'),
            'source' => $this->option('source'),
        ];

        if ($this->generator->generate($target, $options)) {
            $this->info("Created: {$target}");

            return;
        }

        $this->error("Could not create: {$target}");
    }
487615
public function handle()
    {
        if (count($jobs = $this->getFailedJobs()) === 0) {
            return $this->info('No failed jobs!');
        }

        $this->displayFailedJobs($jobs);
    }
281194
public function handle()
    {
        $params = [
            'tables'   => $this->argument('tables'),
            '--tables' => $this->option('tables'),
            '--ignore' => $this->option('ignore'),
        ];

        $this->call('generator:make:migration', $params);

        $params['--models'] = $this->option('models');

        $this->call('generator:make:scaffold', $params);

        $this->call('generator:make:factory', $params);
    }