src/classes/Console/Commands/MakeTransformerCommand.php
private function makeTemplate($transformer, $model, $template)
    {
        $template = !empty($template) ? "-{$template}" : "";
        $file = __DIR__ . "/../templates/transformer/transformer{$template}.php.dist";

        if (file_exists($file))
        {
            $template = strtr(file_get_contents($file), [
                '{{namespace}}' => get_app_namespace(),
                '{{transformer}}' => $transformer,
                '{{model}}' => $model,
                '{{model_small}}' => strtolower($model),
            ]);

            if (!file_exists(app_path("Transformers")))
            {
                mkdir(app_path("Transformers"), 0755, true);
            }

            $file_path = app_path("Transformers/{$transformer}.php");

            $file = fopen($file_path, "w");
            fwrite($file, $template);
            fclose($file);

            return file_exists($file_path);
        }

        return false;
    }
private function makeTemplate($transformer, $model, $template)
    {
        $template = !empty($template) ? "-{$template}" : "";
        $file = __DIR__ . "/../templates/transformer/transformer{$template}.php.dist";

        if (file_exists($file))
        {
            $template = strtr(file_get_contents($file), [
                '{{namespace}}' => get_app_namespace(),
                '{{transformer}}' => $transformer,
                '{{model}}' => $model,
                '{{model_small}}' => strtolower($model),
            ]);

            if (!file_exists(app_path("Transformers")))
            {
                mkdir(app_path("Transformers"), 0755, true);
            }

            $file_path = app_path("Transformers/{$transformer}.php");

            $file = fopen($file_path, "w");
            fwrite($file, $template);
            fclose($file);

            return file_exists($file_path);
        }

        return false;
    }
private function makeTemplate ( $ transformer , $ model , $ template ) { $ template = ! empty ( $ template ) ? "-{$template}" : "" ; $ file = __DIR__ . "/../templates/transformer/transformer{$template}.php.dist" ; if ( file_exists ( $ file ) ) { $ template = strtr ( file_get_contents ( $ file ) , [ '{{namespace}}' => get_app_namespace ( ) , '{{transformer}}' => $ transformer , '{{model}}' => $ model , '{{model_small}}' => strtolower ( $ model ) , ] ) ; if ( ! file_exists ( app_path ( "Transformers" ) ) ) { mkdir ( app_path ( "Transformers" ) , 0755 , true ) ; } $ file_path = app_path ( "Transformers/{$transformer}.php" ) ; $ file = fopen ( $ file_path , "w" ) ; fwrite ( $ file , $ template ) ; fclose ( $ file ) ; return file_exists ( $ file_path ) ; } return false ; }
Create the transformer template.

@depends handle
@param  string $transformer
@param  string $model
@param  boolean $template
@return boolean
Create the transformer template .