PHP code example of sammakescode / laravel-command-switches

1. Go to this page and download the library: Download sammakescode/laravel-command-switches library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sammakescode / laravel-command-switches example snippets


    use SamMakesCode\CommandSwitches\Traits\Switchable;

    if ($this->isOff()) {
        \Log::notice($this->signature . ' is switched off');
        return;
    }
    // Your functionality

    if ($this->isOn()) {
        // Your functionality
    }



namespace App\Console\Commands;

use Illuminate\Console\Command;
use SamMakesCode\CommandSwitches\Traits\Switchable;

class SomeCommand extends Command
{
    use Switchable;

    protected $signature = 'some-command';

    protected $description = 'Command description';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        if ($this->isOn()) {
            // Your functionality
        }
    }
}

    \SamMakesCode\CommandSwitches\CommandSwitch::findOrCreate(SomeCommand::class)->setOn();