<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Master\Models\VehicleModel;

class CapRemoveModels extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cap:remove-models';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Remove Cap Models';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $count = VehicleModel::query()
            ->whereNull('autotrader_id')
            ->where(function ($query) {
                $query->whereNotNull('cap_id')
                    ->orWhereNotNull('lcv_cap_id');
            })
            ->delete();

        $this->info($count . ' removed');


        return 0;
    }
}
