Skip to content

Commit 95e95db

Browse files
committed
Make it compatible with Laravel 6+
1 parent 2259e94 commit 95e95db

31 files changed

+65
-57
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "crestapps/laravel-code-generator",
33
"license": "MIT",
44
"description": "An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.",
5-
"version": "v2.3.3",
5+
"version": "2.4.0",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

src/Commands/ApiDocs/CreateApiDocsControllerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function getCommandInput()
261261
{
262262
$modelName = trim($this->argument('model-name'));
263263
$cName = trim($this->option('controller-name'));
264-
$controllerName = $cName ? str_finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
264+
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
265265
$prefix = ($this->option('routes-prefix') == 'default-form') ? Helpers::makeRouteGroup($modelName) : $this->option('routes-prefix');
266266
$resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
267267
$force = $this->option('force');

src/Commands/ApiDocs/CreateApiDocsViewCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,22 @@ protected function getValidationRules(Field $field)
319319
continue;
320320
}
321321

322-
if ($hasString && starts_with($rule, 'min:')) {
322+
if ($hasString && Str::startsWith($rule, 'min:')) {
323323
$rules[] = 'Minimum Length: ' . Str::trimEnd($rule, 'min:');
324324
continue;
325325
}
326326

327-
if ($hasString && starts_with($rule, 'max:')) {
327+
if ($hasString && Str::startsWith($rule, 'max:')) {
328328
$rules[] = 'Maximum Length: ' . Str::trimEnd($rule, 'max:');
329329
continue;
330330
}
331331

332-
if ($hasNumber && starts_with($rule, 'min:')) {
332+
if ($hasNumber && Str::startsWith($rule, 'min:')) {
333333
$rules[] = 'Minimum Value: ' . Str::trimEnd($rule, 'min:');
334334
continue;
335335
}
336336

337-
if ($hasNumber && starts_with($rule, 'max:')) {
337+
if ($hasNumber && Str::startsWith($rule, 'max:')) {
338338
$rules[] = 'Maximum Value: ' . Str::trimEnd($rule, 'max:');
339339
continue;
340340
}
@@ -548,7 +548,7 @@ protected function getCommandInput()
548548
{
549549
$modelName = trim($this->argument('model-name'));
550550
$cName = trim($this->option('controller-name'));
551-
$controllerName = $cName ? str_finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
551+
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
552552
$controllerDirectory = trim($this->option('controller-directory'));
553553
$viewsDirectory = trim($this->option('views-directory'));
554554
$layoutName = trim($this->option('layout-name'));

src/Commands/Bases/ControllerCommandBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected function getCommandInput()
183183
{
184184
$modelName = trim($this->argument('model-name'));
185185
$cName = trim($this->option('controller-name'));
186-
$controllerName = $cName ? str_finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
186+
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
187187
$prefix = ($this->option('routes-prefix') == 'default-form') ? Helpers::makeRouteGroup($modelName) : $this->option('routes-prefix');
188188
$perPage = intval($this->option('models-per-page'));
189189
$resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
@@ -486,7 +486,7 @@ protected function getRelationCollections(array $fields, $view)
486486
protected function getRequestsNamespace($name, $path)
487487
{
488488
if (!empty($path)) {
489-
$path = str_finish($path, '\\');
489+
$path = Str::finish($path, '\\');
490490
}
491491

492492
$path = Helpers::getAppNamespace() . Config::getRequestsPath($path);

src/Commands/Bases/ControllerRequestCommandBase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use CrestApps\CodeGenerator\Traits\CommonCommand;
99
use CrestApps\CodeGenerator\Traits\GeneratorReplacers;
1010
use Illuminate\Console\Command;
11+
use CrestApps\CodeGenerator\Support\Str;
1112

1213
class ControllerRequestCommandBase extends Command
1314
{
@@ -174,7 +175,7 @@ protected function extractCustomValidationRules(array $rules)
174175
*/
175176
protected function isCustomRule($rule)
176177
{
177-
return starts_with(trim($rule), 'new ');
178+
return Str::startsWith(trim($rule), 'new ');
178179
}
179180

180181
/**
@@ -212,7 +213,7 @@ protected function getCustomRuleShortName($rule)
212213
*/
213214
protected function canHaveUsingCommand($fullname)
214215
{
215-
return !starts_with($fullname, '\\');
216+
return !Str::startsWith($fullname, '\\');
216217
}
217218

218219
/**

src/Commands/Bases/ResourceFileCreatorCommandBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getCommandInput()
3434
{
3535
$modelName = trim($this->argument('model-name'));
3636
$filename = trim($this->option('resource-filename'));
37-
$file = $filename ? str_finish($filename, '.json') : Helpers::makeJsonFileName($modelName);
37+
$file = $filename ? Str::finish($filename, '.json') : Helpers::makeJsonFileName($modelName);
3838
$translationFor = array_unique(Arr::fromString($this->option('translation-for')));
3939
$fieldNames = array_unique(Arr::fromString($this->option('fields')));
4040
$relations = Arr::fromString($this->option('relations'));

src/Commands/Framework/CreateFormRequestCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use CrestApps\CodeGenerator\Models\Resource;
77
use CrestApps\CodeGenerator\Support\Config;
88
use CrestApps\CodeGenerator\Support\Helpers;
9+
use CrestApps\CodeGenerator\Support\Str;
910

1011
class CreateFormRequestCommand extends ControllerRequestCommandBase
1112
{
@@ -184,7 +185,7 @@ protected function isConvertEmptyStringsToNullRegistered()
184185
*/
185186
protected function getDestenationFile($name, $path)
186187
{
187-
return str_finish(app_path(Config::getRequestsPath($path)), '/') . $name . '.php';
188+
return Str::finish(app_path(Config::getRequestsPath($path)), '/') . $name . '.php';
188189
}
189190

190191
/**
@@ -196,7 +197,7 @@ protected function getDestenationFile($name, $path)
196197
*/
197198
protected function getRequestsNamespace($path)
198199
{
199-
$path = str_finish($path, '\\');
200+
$path = Str::finish($path, '\\');
200201

201202
$path = Helpers::getAppNamespace() . Config::getRequestsPath($path);
202203

src/Commands/Framework/CreateMigrationCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use CrestApps\CodeGenerator\Models\MigrationTrackerCapsule;
1313
use CrestApps\CodeGenerator\Models\Resource;
1414
use CrestApps\CodeGenerator\Support\Arr;
15+
use CrestApps\CodeGenerator\Support\Str;
1516
use CrestApps\CodeGenerator\Support\Config;
1617
use CrestApps\CodeGenerator\Support\Helpers;
1718
use CrestApps\CodeGenerator\Support\MigrationHistoryTracker;
@@ -211,7 +212,7 @@ protected function getMigrationFullName($name)
211212
$folder = $this->tableName;
212213
}
213214

214-
return str_finish($this->getMigrationPath($folder) . DIRECTORY_SEPARATOR . $name, '.php');
215+
return Str::finish($this->getMigrationPath($folder) . DIRECTORY_SEPARATOR . $name, '.php');
215216
}
216217

217218
/**

src/Commands/Framework/CreateModelCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ protected function replaceMutators(&$stub, $mutators)
818818
protected function replaceFieldName(&$stub, $name)
819819
{
820820
$stub = $this->strReplace('field_name', $name, $stub);
821-
$stub = $this->strReplace('field_name_cap', ucwords(camel_case($name)), $stub);
821+
$stub = $this->strReplace('field_name_cap', ucwords(Str::camel($name)), $stub);
822822

823823
return $this;
824824
}

src/Commands/Resources/ResourceFileDeleteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function getCommandInput()
5959
{
6060
$modelName = trim($this->argument('model-name'));
6161
$filename = trim($this->option('resource-filename'));
62-
$file = $filename ? str_finish($filename, '.json') : Helpers::makeJsonFileName($modelName);
62+
$file = $filename ? Str::finish($filename, '.json') : Helpers::makeJsonFileName($modelName);
6363

6464
return (object) compact('modelName', 'file');
6565
}

0 commit comments

Comments
 (0)