/** * Generate a file based off of a template * * @param $fileName * @param $template * @param string $content */ public function makeFileFromTemplate($fileName, $template, $content = "") { try { $fileContents = \File::get($template); } catch (FileNotFoundException $e) { $shortTemplate = substr($template, strpos($template, $this->configSettings["pathTo"]["templates"]) + strlen($this->configSettings["pathTo"]["templates"]), strlen($template) - strlen($this->configSettings["pathTo"]["templates"])); $this->fileCreator->copyFile("vendor/jrenton/laravel-scaffold/src/Jrenton/LaravelScaffold/templates/" . $shortTemplate, $template); $fileContents = \File::get($template); } $fileContents = $this->replaceNames($fileContents); $fileContents = $this->replaceModels($fileContents); $fileContents = $this->replaceProperties($fileContents); if ($content) { $fileContents = str_replace("[content]", $content, $fileContents); } $namespace = $this->namespace ? "namespace " . $this->namespace . ";" : ""; $fileContents = str_replace("[namespace]", $namespace, $fileContents); if (!$this->configSettings['useRepository']) { $fileContents = str_replace($this->nameOf("repositoryInterface"), $this->nameOf("modelName"), $fileContents); } $this->fileCreator->createFile($fileName, $fileContents); }