<?php

namespace App\Services\Tg\Hook\Mod;
use App\Models\Option as ModelOption;
use App\Services\Tg\Hook\Dog;
use Illuminate\Support\Facades\Artisan;

class Console extends Base {
    
    private $oDog;

    public function __construct($aUpdate = [])
    {
        $this->oDog = new Dog(new ModelOption());
//        $this->oDog->_setPrimaryKey("k"); // 可选，默认id
        $this->oDog->_setDogName("console"); // 必须
    }
    
    public function __call($sName, $aArg)
    {
        return $this->oDog->$sName($aArg[0]);
    }
    
    public function call($aParam)
    {
        $sName = $aParam["aArg"][1] ?? '';
        
        if ($sName == "?") {
            return "call [sName] 案例：stat:tags-count";
        }
        
        if (!$sName) {
            return "需要name";
        }
        
        $iExitCode = Artisan::call($sName);
        $sOutput = Artisan::output();

        return $sOutput;
    }
    
    public function t()
    {
        echo 11;
        exit;
    }
    
}
