diff --git a/README.md b/README.md index 4f87f4f..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,11 +0,0 @@ -Laravel Generator -============================== - -[](https://packagist.org/packages/infyomlabs/laravel-generator) -[](https://packagist.org/packages/infyomlabs/laravel-generator) -[](https://packagist.org/packages/infyomlabs/laravel-generator) -[](https://packagist.org/packages/infyomlabs/laravel-generator) -[](https://packagist.org/packages/infyomlabs/laravel-generator) -[](https://packagist.org/packages/infyomlabs/laravel-generator) - -Documentation is located [here](http://labs.infyom.com/laravelgenerator) diff --git a/src/Commands/Publish/VueJsLayoutPublishCommand.php b/src/Commands/Publish/VueJsLayoutPublishCommand.php index 39d030f..b017769 100644 --- a/src/Commands/Publish/VueJsLayoutPublishCommand.php +++ b/src/Commands/Publish/VueJsLayoutPublishCommand.php @@ -3,6 +3,7 @@ namespace InfyOm\Generator\Commands\Publish; use InfyOm\Generator\Utils\FileUtil; +use Illuminate\Support\Str; class VueJsLayoutPublishCommand extends PublishBaseCommand { @@ -35,7 +36,7 @@ class VueJsLayoutPublishCommand extends PublishBaseCommand public function handle() { $version = $this->getApplication()->getVersion(); - if (str_contains($version, '5.1')) { + if (Str::contains($version, '5.1')) { $this->laravelVersion = '5.1'; } else { $this->laravelVersion = '5.2'; diff --git a/src/Common/BaseRepository.php b/src/Common/BaseRepository.php index 1737cbb..d0621ae 100644 --- a/src/Common/BaseRepository.php +++ b/src/Common/BaseRepository.php @@ -3,6 +3,7 @@ namespace InfyOm\Generator\Common; use Exception; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Log; abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepository @@ -54,11 +55,10 @@ public function updateRelations($model, $attributes) $methodClass = get_class($model->$key($key)); switch ($methodClass) { case 'Illuminate\Database\Eloquent\Relations\BelongsToMany': - $new_values = array_get($attributes, $key, []); + $new_values = Arr::get($attributes, $key, []); if (array_search('', $new_values) !== false) { unset($new_values[array_search('', $new_values)]); } - Log::info(array_values($new_values)); // if(count(array_values($new_values)) === 0){ // $pivot = $model->$key()->detach(array_values($new_values)); // }else{ @@ -71,7 +71,7 @@ public function updateRelations($model, $attributes) break; case 'Illuminate\Database\Eloquent\Relations\BelongsTo': $model_key = $model->$key()->getQualifiedForeignKey(); - $new_value = array_get($attributes, $key, null); + $new_value = Arr::get($attributes, $key, null); $new_value = $new_value == '' ? null : $new_value; $model->$model_key = $new_value; break; @@ -80,7 +80,7 @@ public function updateRelations($model, $attributes) case 'Illuminate\Database\Eloquent\Relations\HasOneOrMany': break; case 'Illuminate\Database\Eloquent\Relations\HasMany': - $new_values = array_get($attributes, $key, []); + $new_values = Arr::get($attributes, $key, []); if (array_search('', $new_values) !== false) { unset($new_values[array_search('', $new_values)]); } diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index 925af63..42d2154 100644 --- a/src/Common/GeneratorConfig.php +++ b/src/Common/GeneratorConfig.php @@ -304,8 +304,8 @@ public function prepareModelNames() $this->mDashedPlural = str_replace('_', '-', Str::snake($this->mSnakePlural)); $this->mSlash = str_replace('_', '/', Str::snake($this->mSnake)); $this->mSlashPlural = str_replace('_', '/', Str::snake($this->mSnakePlural)); - $this->mHuman = title_case(str_replace('_', ' ', Str::snake($this->mSnake))); - $this->mHumanPlural = title_case(str_replace('_', ' ', Str::snake($this->mSnakePlural))); + $this->mHuman = Str::title(str_replace('_', ' ', Str::snake($this->mSnake))); + $this->mHumanPlural = Str::title(str_replace('_', ' ', Str::snake($this->mSnakePlural))); } public function prepareOptions(CommandData &$commandData) diff --git a/src/Common/GeneratorFieldRelation.php b/src/Common/GeneratorFieldRelation.php index efa7deb..055ce35 100644 --- a/src/Common/GeneratorFieldRelation.php +++ b/src/Common/GeneratorFieldRelation.php @@ -1,6 +1,7 @@ inputs[0]; switch ($this->type) { case '1t1': - $functionName = camel_case($modelName); + $functionName = Str::camel($modelName); $relation = 'hasOne'; $relationClass = 'HasOne'; break; case '1tm': - $functionName = camel_case(str_plural($modelName)); + $functionName = Str::camel(Str::plural($modelName)); $relation = 'hasMany'; $relationClass = 'HasMany'; break; case 'mt1': - $functionName = camel_case($modelName); + $functionName = Str::camel($modelName); $relation = 'belongsTo'; $relationClass = 'BelongsTo'; break; case 'mtm': - $functionName = camel_case(str_plural($modelName)); + $functionName = Str::camel(Str::plural($modelName)); $relation = 'belongsToMany'; $relationClass = 'BelongsToMany'; break; case 'hmt': - $functionName = camel_case(str_plural($modelName)); + $functionName = Str::camel(Str::plural($modelName)); $relation = 'hasManyThrough'; $relationClass = 'HasManyThrough'; break; diff --git a/src/Generators/ModelGenerator.php b/src/Generators/ModelGenerator.php index dc9982d..b8e068d 100644 --- a/src/Generators/ModelGenerator.php +++ b/src/Generators/ModelGenerator.php @@ -3,6 +3,7 @@ namespace InfyOm\Generator\Generators; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Str; use InfyOm\Generator\Common\CommandData; use InfyOm\Generator\Common\GeneratorFieldRelation; use InfyOm\Generator\Utils\FileUtil; @@ -192,12 +193,12 @@ private function getPHPDocType($db_type, $relation = null) return 'string'; case '1t1': case 'mt1': - return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.camel_case($relation->inputs[0]); + return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.Str::camel($relation->inputs[0]); case '1tm': return '\Illuminate\Database\Eloquent\Collection'.' '.$relation->inputs[0]; case 'mtm': case 'hmt': - return '\Illuminate\Database\Eloquent\Collection'.' '.camel_case($relation->inputs[0]); + return '\Illuminate\Database\Eloquent\Collection'.' '.Str::camel($relation->inputs[0]); default: return $db_type; } @@ -231,7 +232,7 @@ private function generateRequiredFields() foreach ($this->commandData->fields as $field) { if (!empty($field->validations)) { - if (str_contains($field->validations, 'required')) { + if (Str::contains($field->validations, 'required')) { $requiredFields[] = $field->name; } } diff --git a/src/Generators/Scaffold/ViewGenerator.php b/src/Generators/Scaffold/ViewGenerator.php index aed1bd4..107f6a9 100644 --- a/src/Generators/Scaffold/ViewGenerator.php +++ b/src/Generators/Scaffold/ViewGenerator.php @@ -219,7 +219,7 @@ private function getTransArray($string = ''){ } return $result; } - + private function getLangArray(){ $mSnake = $this->commandData->config->mSnake; $lang = [ @@ -231,7 +231,7 @@ private function getLangArray(){ $mSnake."_create" => $this->getTransArray('Create '.$this->commandData->config->mHuman), ]; foreach ($this->commandData->fields as $field) { - $title = preg_replace('/-|_/',' ',title_case($field->name)); + $title = preg_replace('/-|_/',' ',Str::title($field->name)); if($field->inIndex || $field->inForm){ $lang[$mSnake.'_'.$field->name] = $this->getTransArray($title); } @@ -246,7 +246,7 @@ private function getLangArray(){ private function generateFields() { $this->htmlFields = []; - $startSeparator = '