/** * Creates the model file */ private function createModel() { $fileName = $this->configSettings['pathTo']['models'] . $this->nameOf("modelName") . ".php"; if (\File::exists($fileName)) { $this->updateModel($fileName); $this->model->exists = true; return; } $fileContents = "protected \$table = '" . $this->model->getTableName() . "';\n"; if (!$this->model->hasTimestamps()) { $fileContents .= "\tpublic \$timestamps = false;\n"; } if ($this->model->hasSoftdeletes()) { $fileContents .= "\tprotected \$softDelete = true;\n"; } $properties = ""; foreach ($this->model->getProperties() as $property => $type) { $properties .= "'{$property}',"; } $properties = rtrim($properties, ","); $fileContents .= "\tprotected \$fillable = array(" . $properties . ");\n"; $fileContents = $this->addRelationships($fileContents); $template = $this->configSettings['useRepository'] ? "model.txt" : "model-no-repo.txt"; $this->makeFileFromTemplate($fileName, $this->configSettings['pathTo']['templates'] . $template, $fileContents); $this->addModelLinksToLayoutFile(); }