OptimizeUsers.php 656 Bytes
<?php

namespace App\Console\Commands;

use App\Models\Employer;
use App\Models\Worker;
use Illuminate\Console\Command;

class OptimizeUsers extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'optimize:users';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
         Employer::doesntHave('users')->delete();
         Worker::doesntHave('users')->delete();

    }
}