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/egovers/edwingovers.nl/app/KommaApp/Shop/ArtisanCommands/IndexSearch.php
<?php

namespace App\KommaApp\Shop\ArtisanCommands;

use App\KommaApp\Shop\Categories\Models\Category;
use App\KommaApp\Shop\Categories\Models\CategoryTranslation;
use App\KommaApp\Shop\Products\Product\Product;
use App\KommaApp\Shop\Products\Product\ProductTranslation;
use App\KommaApp\Shop\Products\ProductComposite\ProductComposite;
use App\KommaApp\Shop\Products\ProductComposite\ProductCompositeTranslation;
use App\KommaApp\Shop\Products\ProductGroup\ProductGroup;
use App\KommaApp\Shop\Products\ProductGroup\ProductGroupTranslation;
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->info('Importing models for the search index. Please wait...');
                $this->call('scout:import', ['model' => Product::class]);
                $this->call('scout:import', ['model' => ProductTranslation::class]);
                $this->call('scout:import', ['model' => ProductGroup::class]);
                $this->call('scout:import', ['model' => ProductGroupTranslation::class]);
                $this->call('scout:import', ['model' => ProductComposite::class]);
                $this->call('scout:import', ['model' => ProductCompositeTranslation::class]);
                $this->call('scout:import', ['model' => Category::class]);
                $this->call('scout:import', ['model' => CategoryTranslation::class]);
                $this->info('Importing complete');
            break;
            case "flush":
                $this->info('Flushing models for the search index. Please wait...');
                $this->call('scout:flush', ['model' => Product::class]);
                $this->call('scout:flush', ['model' => ProductTranslation::class]);
                $this->call('scout:flush', ['model' => ProductGroup::class]);
                $this->call('scout:flush', ['model' => ProductGroupTranslation::class]);
                $this->call('scout:flush', ['model' => ProductComposite::class]);
                $this->call('scout:flush', ['model' => ProductCompositeTranslation::class]);
                $this->call('scout:flush', ['model' => Category::class]);
                $this->call('scout:flush', ['model' => CategoryTranslation::class]);
                $this->info('Flushing complete');
                break;
        }
    }
}