<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class OptimizeApp extends Command
{
    protected $signature = 'optimize:app';
    protected $description = 'Optimize the application by clearing caches and other performance improvements';

    public function handle()
    {
        $this->info('Starting optimization process...');

        // Clear the application cache
        $this->call('cache:clear');
        $this->info('Application cache cleared.');

        // Clear the route cache
        $this->call('route:clear');
        $this->info('Route cache cleared.');

        // Clear the config cache
        $this->call('config:clear');
        $this->info('Configuration cache cleared.');

        // Clear the view cache
        $this->call('view:clear');
        $this->info('Compiled views cleared.');

        // Optimize the configuration loading
        $this->call('config:cache');
        $this->info('Configuration cache optimized.');

        // Optimize the application
        $this->call('optimize');
        $this->info('Application optimized.');

        $this->info('Optimization process completed successfully!');
    }
}
