Handle directive

@return string
772604
public function message(string $path) : string
  {
    $path = $this->getPath($path);
    return self::$engine == 'modulus' ? "{% extends($path) %}" : "@extends($path)";
  }
431561
public function handle()
    {
        $options     = $this->getOptions();
        $root = base_path('themes');
        $stubsPath   = __DIR__ . '/../../resources/stubs/theme';
        $slug        = $options['slug'];
        $name        = $this->format($slug);

        if (File::isDirectory($root . '/' . $name)) {
            return $this->error('Theme already exists!');
        }

        if (! File::isDirectory($root)) {
            File::makeDirectory($root);
        }

        foreach (File::allFiles($stubsPath) as $file) {
            $contents = $this->replacePlaceholders($file->getContents(), $options);
            $subPath  = $file->getRelativePathname();
            $filePath = $root.'/'.$options['name'].'/'.$subPath;
            $dir      = dirname($filePath);

            if (! File::isDirectory($dir)) {
                File::makeDirectory($dir, 0755, true);
            }

            File::put($filePath, $contents);
        }

        $this->info("Theme created successfully.");
    }
788946
public function handle()
    {
        $command = $this->option('command');

        ob_start();
        $result = $this->executeCode(
            trim(trim($command), ';').';'
        );
        $output = ob_get_clean();

        if (empty($output) === false) {
            $this->line($output);
            $result = null;
        }

        $this->getOutput()->write('=> ');
        switch (gettype($result)) {
            case 'object':
            case 'array':
                $this->line(var_export($result, true));
                break;
            case 'string':
                $this->comment($result);
                break;
            case 'NULL':
                $this->line('');
                break;
            default:
                is_numeric($result) === true ? $this->info($result) : $this->line($result);
                break;
        }
    }
306917
public function handle()
    {
        $manifest['lang'] = $this->ask('Enter the language', 'en-us');
        $manifest['name'] = $this->ask('Enter the name of your app', 'Laravel & Angular');
        $manifest['short_name'] = $this->ask('Enter the short name of your app', 'Laravel & Angular');
        $manifest['display'] = $this->anticipate('Choose a display type? [fullscreen|standalone|minimal-ui|browser]', ['fullscreen', 'standalone', 'minimal-ui', 'browser'], 'standalone');
        $manifest['start_url'] = $this->ask('Enter the start url', '/?homescreen=1');
        $manifest['background_color'] = $this->ask('Enter a background color: ', '#ffffff');
        $manifest['theme_color'] = $this->ask('Enter your theme color', '#0690B7');

        $manifest['icons'] = [[
                'src'   => 'img/icon.png',
                'sizes' => '198x198',
                'type'  => 'image/png',
            ]];

        $output = json_encode($manifest, JSON_PRETTY_PRINT);

        file_put_contents('public/manifest.json', $output);

        $this->info("Manifest generated successfully.\r\nDon't forget to update your icon in public/img/icon.png");
    }
177637
public function getCleanParam()
    {
        if (empty($this->cleanparam)) {
            $this->log[] = self::DIRECTIVE_CLEAN_PARAM . ' directive: Not found';
        }
        return $this->cleanparam;
    }
202499
public function handle()
    {
        $contents = $this->blueprint->generate($this->getControllers(), $this->getDocName(), $this->getVersion(), $this->getIncludePath());

        if ($file = $this->option('output-file')) {
            $this->writer->write($contents, $file);

            return $this->info('Documentation was generated successfully.');
        }

        return $this->line($contents);
    }
681188
public function handle()
	{
		if ($this->files->isDirectory($this->getPath(null))){
			return $this->error('Theme "'.$this->getTheme().'" is already exists.');
		}

		$this->makeDirs([
						'assets/css',
						'assets/js',
						'assets/img',
						'layouts',
						'partials/sections',
						'views',
						'widgets',
						]);

		$this->makeFiles([
						'layout.blade.php'	=> 'layouts/',
						'header.blade.php'	=> 'partials/',
						'footer.blade.php'	=> 'partials/',
						'main.blade.php'	=> 'partials/sections/',
						'index.blade.php'	=> 'views/',
						'style.css'			=> 'assets/css/',
						'script.js'			=> 'assets/js/',
						'theme.json'		=> '',
						'gulpfile.js'		=> '',
						'config.php'		=> ''
						]);

		$this->info('Theme "'.$this->getTheme().'" has been created.');
	}
1247664
public function handle()
    {
        Deprecation::notice('5.0', 'handle() will be removed. Use addToCampaign or Form directly');
        $object = $this->getObject($this->data['ID'], $this->data['ClassName']);

        if (empty($this->data['Campaign'])) {
            return $this->Form($object)->forTemplate();
        } else {
            return $this->addToCampaign($object, $this->data['Campaign']);
        }
    }
1022299
public function handle()
    {
        $name = $this->argument('name');
        $modelName = str_singular($name);
        $migrationName = str_plural(strtolower($name));
        $tableName = $migrationName;
        $viewName = strtolower($name);

        $routeGroup = $this->option('route-group');
        $this->routeName = ($routeGroup) ? $routeGroup . '/' . strtolower($name) : strtolower($name);

        $controllerNamespace = ($this->option('namespace')) ? $this->option('namespace') . '\\' : '';

        $fields = $this->option('fields');
        $primaryKey = $this->option('pk');
        $viewPath = $this->option('view-path');

        $fieldsArray = explode(',', $fields);
        $requiredFields = '';
        $requiredFieldsStr = '';

        foreach ($fieldsArray as $item) {
            $fillableArray[] = preg_replace("/(.*?):(.*)/", "$1", trim($item));

            $itemArray = explode(':', $item);
            $currentField = trim($itemArray[0]);
            $requiredFieldsStr .= (isset($itemArray[2])
                && (trim($itemArray[2]) == 'req'
                    || trim($itemArray[2]) == 'required'))
            ? "'$currentField' => 'required', " : '';
        }

        $commaSeparetedString = implode("', '", $fillableArray);
        $fillable = "['" . $commaSeparetedString . "']";

        $requiredFields = ($requiredFieldsStr != '') ? "[" . $requiredFieldsStr . "]" : '';

        $this->call('crud:controller', ['name' => $controllerNamespace . $name . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--view-path' => $viewPath, '--required-fields' => $requiredFields, '--route-group' => $routeGroup]);
        $this->call('crud:model', ['name' => $modelName, '--fillable' => $fillable, '--table' => $tableName]);
        $this->call('crud:migration', ['name' => $migrationName, '--schema' => $fields, '--pk' => $primaryKey]);
        $this->call('crud:view', ['name' => $viewName, '--fields' => $fields, '--view-path' => $viewPath, '--route-group' => $routeGroup]);
        // For optimizing the class loader
        $this->callSilent('optimize');

        // Updating the Http/routes.php file old laravels app_path('Http/routes.php')
        $routeFile = config('crudgenerator.route'); //change it to config file
        if (file_exists($routeFile) && (strtolower($this->option('route')) === 'yes')) {
            $this->controller = ($controllerNamespace != '') ? $controllerNamespace . '\\' . $name . 'Controller' : $name . 'Controller';

            if (\App::VERSION() >= '5.2') {
                $isAdded = File::append($routeFile,
                    "\nRoute::group(['middleware' => ['web']], function () {"
                    . "\n\t" . implode("\n\t", $this->addRoutes())
                    . "\n});"
                );
            } else {
                $isAdded = File::append($routeFile, "\n".implode("\n", $this->addRoutes()));
            }

            if ($isAdded) {
                $this->info('Crud/Resource route added to ' . $routeFile);
            } else {
                $this->info('Unable to add the route to ' . $routeFile);
            }
        }
    }
104449
public function handle()
    {
        $path = $this->argument('path');
        $path = str_replace('//', '/', $path);
        if($path=='/'){
            cookie('cd_base_path', base_path(), 45000);
            $this->info(base_path());
            return true;
        }
        $root = cookie('cd_base_path');
        if(strrpos($path, "../")!==false){
            $clear = str_replace(base_path(),'',$root);
            $clear = str_replace("\\","",$clear);
            $clear = trim($clear, '/');
            $root = explode('/', $clear);
            foreach (explode('/', $path) as $pat) if($pat=='..') {array_pop($root);}
            $root = array_diff($root, array(''));
            $root = trim(implode('/', $root), '/');
            $root = base_path($root);
            $path = str_replace('../','',$path);
        }
        $path = trim($root, '/').($path && !empty($path)!=='/'?'/':'').$path;
        $path = str_replace('//', '/', $path);
        if(!is_dir($path)){
            $this->error("Path \"{$path}\" not found!");
            return true;
        }
        $path = str_replace("\\\\","\\", $path);
        cookie('cd_base_path', $path, 45000);
        $this->info($path);
    }
937933
public function handle()
    {
        $input = $this->getCommandInput();
        $file = $this->getFilename($input->file);

        if (!$this->isFileExists($file)) {
            $this->error('The resource-file does not exists!');

            return false;
        }

        $resource = $this->getResources($file, $input->translationFor);

        $resource->setDefaultApiDocLabels($input->modelName, self::makeLocaleGroup($input->modelName), $input->translationFor);

        dd($resource->toArray());

        $content = Helpers::prettifyJson($resource->toArray());

        $this->putContentInFile($file, $content);
    }
913089
public function handle()
    {
        $tableName = $this->argument('table');
        $filePath  = $this->argument('file_path');

        $includeId = $this->option('include_id');

        $columnNames = [];

        $columnInformation = \DB::select('show columns from '.$tableName);
        if (!empty($this->option('columns'))) {
            $columnNames = explode(',', $this->option('columns'));
        } else {
            if ($includeId) {
                $columnNames[] = 'id';
            }
            foreach ($columnInformation as $entity) {
                if ($entity->Field !== 'id') {
                    $columnNames[] = $entity->Field;
                }
            }
        }
        $defaultValues = [];
        foreach ($columnInformation as $entity) {
            if ($entity->null === 'NO') {
                $type = $entity->Type;
                if (Str::startsWith($type, 'varchar') || Str::startsWith($type, 'char') || Str::startsWith($type, 'text')) {
                    $defaultValues[$entity->Field] = '';
                } else {
                    $defaultValues[$entity->Field] = 0;
                }
            }
        }

        $excel = app()->make(Excel::class);
        $excel->filter('chunk')->load($filePath)->chunk(250, function($results) use ($tableName, $columnNames, $defaultValues) {
            foreach ($results as $row) {
                $data = [];
                foreach ($columnNames as $columnName) {
                    if ($row->has($columnName) && !empty($row->get($columnName))) {
                        $data[$columnName] = $row->get($columnName);
                    } elseif (array_key_exists($columnName, $defaultValues)) {
                        $data[$columnName] = $defaultValues[$columnName];
                    }
                }
                \DB::table($tableName)->insert($data);
            }
        });

        return true;
    }
51869
public function handle()
    {
        foreach ($this->loaders as $loader) {
            if ($language = call_user_func($loader)) {
                if (in_array($language, $this->supportedLanguages)) {
                    return $language;
                }

                $special = strpos($language, '-') !== false;
                if ($special && $this->allowFallback &&
                    in_array(substr($language, 0, 2), $this->supportedLanguages)) {
                    return substr($language, 0, 2);
                }

                if ( ! $special && $this->allowAdvance) {
                    foreach ($this->supportedLanguages as $supportedLanguage) {
                        if ($language === substr($supportedLanguage, 0, 2)) {
                            return $supportedLanguage;
                        }
                    }
                }
            }
        }

        return false;
    }
819146
public function handle()
    {
        $this->createFilter();

        if (parent::handle() === false) return false;

        $this->generateTranslation();

        return true;
    }
1247200
protected function handleText()
    {
        $content = $this->getContent();
        foreach ($this->rules['text'] as $rule) {
            if ($rule['type'] == 'is' && 0 === strcasecmp($content, $rule['keyword'])) {
                return $this->handle($rule['fn']);
            }

            if ($rule['type'] == 'has' && false !== mb_stripos($content, $rule['keyword'])) {
                return $this->handle($rule['fn']);
            }

            if ($rule['type'] == 'startsWith' && 0 === mb_stripos($content, $rule['keyword'])) {
                return $this->handle($rule['fn']);
            }

            if ($rule['type'] == 'match' && preg_match($rule['keyword'], $content)) {
                return $this->handle($rule['fn']);
            }
        }
        return false;
    }
222264
public function handle()
    {
        $name = $this->argument('name');
        $studly_name = studly_case($name);

        $js = file_get_contents(__DIR__.'/Stubs/AngularService/service.js.stub');
        $spec = file_get_contents(__DIR__.'/Stubs/AngularService/service.spec.js.stub');

        $js = str_replace('{{StudlyName}}', $studly_name, $js);
        $spec = str_replace('{{StudlyName}}', $studly_name, $spec);

        $folder = base_path(config('generators.source.root')).'/'.config('generators.source.services');

        $spec_folder = base_path(config('generators.tests.source.root')).'/'.config('generators.tests.source.services');

        if(!File::exists($folder))
            File::makeDirectory($folder, 0775, true);
        
        //create service (.service.js)
        if(!File::exists($folder.'/'.$name.config('generators.suffix.service')))
            File::put($folder.'/'.$name.config('generators.suffix.service'), $js);
        else{
            $this->info('Service already exists.');
            return false;
        }

        if (!$this->option('no-spec') && config('generators.tests.enable.services')) {
            //create spec folder
            if (!File::exists($spec_folder)) {
                File::makeDirectory($spec_folder, 0775, true);
            }
            //create spec (.service.spec.js)
            File::put($spec_folder.'/'.$name.'.service.spec.js', $spec);
        }

        //import service
        $services_index = base_path(config('generators.source.root')).'/index.services.js';

        if(!config('generators.angular_modules.services.standalone'))
            $module = "angular.module('".config('generators.angular_modules.root')."')";
        else
            $module = "angular.module('"
                      .(config('generators.angular_modules.services.use_prefix') ? config('generators.angular_modules.services.prefix')."." : "")
                      .config('generators.angular_modules.services.suffix')
                      ."', [])";

        if(!file_exists($services_index)){
            File::put($services_index, $module);
        }

        if (config('generators.misc.auto_import') && !$this->option('no-import')) {
            $services = file_get_contents($services_index);
            $newService = "\r\n\t.service('{$studly_name}Service', {$studly_name}Service)";
            $services = str_replace($module, $module.$newService, $services);
            $services = 'import {'.$studly_name."Service} from './services/{$name}.service';\n".$services;
            file_put_contents($services_index, $services);
        }

        $this->info('Service created successfully.');
    }
430896
public function handle()
    {
        $name = ucfirst($this->argument('name'));

        $path = base_path("src/{$name}/");

        try {
            $gn = new Generator($path);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }

        $gn->put("Http/routes.php", "Http/routes.php", [
            'URL' => strtolower($name)
        ]);

        $gn->put("Package.php", "Package.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Resources/views/welcome.blade.php", "Resources/views/welcome.blade.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Resources/public/assets/welcome/main.css", "Resources/public/assets/welcome/main.css");

        $gn->put("Providers/AppServiceProvider.php", "Providers/AppServiceProvider.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Providers/RouteServiceProvider.php", "Providers/RouteServiceProvider.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Http/Controllers/Controller.php", "Http/Controllers/Controller.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Http/Controllers/WelcomeController.php", "Http/Controllers/WelcomeController.php", [
            'NAMESPACE' => $name
        ]);

        $gn->put("Console/Commands/Welcome.php", "Console/Commands/Welcome.php", [
            'NAMESPACE' => $name,
            'NAME' => strtolower($name)
        ]);

        $this->info("\n".$name." generated");
    }