public function modelCommand($table, $service = '', $namespace = 'App\Models', $optimized = false)
    {
        if (strpos($namespace, '\\') === false) {
            $namespace = 'App\\' . ucfirst($namespace) . '\\Models';
        }

        /** @var \ManaPHP\DbInterface $db */
        if ($service) {
            $db = $this->_di->getShared($service);
            if (!in_array($table, $db->getTables(), true)) {
                throw new Exception(['`:table` is not exists', 'table' => $table]);
            }
        } else {
            foreach ($this->_getDbServices() as $s) {
                $db = $this->_di->getShared($s);
                if (in_array($table, $db->getTables(), true)) {
                    $service = $s;
                    break;
                }
            }
            if (!$service) {
                throw new Exception(['`:table` is not found in services`', 'table' => $table]);
            }
        }

        $this->console->progress(['`:table` processing...', 'table' => $table], '');

        $plainClass = Text::camelize($table);
        $fileName = "@tmp/db_model/$plainClass.php";
        $model_str = $this->_renderModel($service, $table, $namespace, $optimized);
        $this->filesystem->filePut($fileName, $model_str);

        $this->console->progress(['`:table` table saved to `:file`', 'table' => $table, 'file' => $fileName]);
    }