HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/conmeq.komma.pro/app/Komma/Shop/ArtisanCommands/IndexSearch.php
<?php

namespace App\Komma\Shop\ArtisanCommands;

use App\Komma\Shop\Catalog\Kms\CatalogService;
use Illuminate\Console\Command;

class IndexSearch extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'shop:searchindex {action? : index, flush. Defaults to index}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Imports the products, groups and composites into the search index so they can be searched trough';

    /**
     * IndexCatalog constructor.
     */
    public function __construct( )
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $action = $this->argument('action');
        if(!$action) $action = null;

        switch ($action)
        {
            case null:
            case "index":
                $this->index();
                break;
            case "flush":
                $this->flush();
                break;
        }

        CatalogService::manageSearchabilityForGivenOrAllTranslatablesWhere(null,'active', 0);
        return null;
    }

    /**
     * Flush imported searchable models from the search databases
     */
    private function flush()
    {
        $this->info('Flushing models for the search index. Please wait...');
        foreach (CatalogService::$searchableModelClasses as $searchModelClassName) $this->call('scout:flush', ['model' => $searchModelClassName]);
        $this->info('Flushing complete');
    }

    /**
     * Import searchable models in the search databases
     */
    private function index()
    {
        $this->info('Importing models for the search index. Please wait...');
        foreach (CatalogService::$searchableModelClasses as $searchModelClassName) $this->call('scout:import', ['model' => $searchModelClassName]);
        $this->info('Importing complete');
    }
}