File "ConfirmableTrait.php"
                                Full Path: /home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/vendor/league/commonmark/src/Renderer/Block/ConfirmableTrait.php
                File size: 1.28 KB
                MIME-type: text/x-php
                Charset: utf-8
            
<?php
namespace Illuminate\Console;
use function Laravel\Prompts\confirm;
trait ConfirmableTrait
{
    /**
     * Confirm before proceeding with the action.
     *
     * This method only asks for confirmation in production.
     *
     * @param  string  $warning
     * @param  \Closure|bool|null  $callback
     * @return bool
     */
    public function confirmToProceed($warning = 'Application In Production', $callback = null)
    {
        $callback = is_null($callback) ? $this->getDefaultConfirmCallback() : $callback;
        $shouldConfirm = value($callback);
        if ($shouldConfirm) {
            if ($this->hasOption('force') && $this->option('force')) {
                return true;
            }
            $this->components->alert($warning);
            $confirmed = confirm('Are you sure you want to run this command?', default: false);
            if (! $confirmed) {
                $this->components->warn('Command cancelled.');
                return false;
            }
        }
        return true;
    }
    /**
     * Get the default confirmation callback.
     *
     * @return \Closure
     */
    protected function getDefaultConfirmCallback()
    {
        return function () {
            return $this->getLaravel()->environment() === 'production';
        };
    }
}