Skip to content

Commit d1734c2

Browse files
committed
Fix #97, #98, #99, #101, #102
1 parent 288ea81 commit d1734c2

12 files changed

+41
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Checkout our channel on <a href="https://www.youtube.com/channel/UCkEd0nOoRf3o0a
128128

129129
## Contribution
130130
Do you like this project and want to contribute?
131+
- **HELP WANTED** Version `v2.3` needs to be documented before it can be released. If you are able to contribute, please read the <a href="https://github.com/CrestApps/laravel-code-generator/blob/v2.3/CHANGELOG.md">change-log</a> in <a href="https://github.com/CrestApps/laravel-code-generator/tree/v2.3">v2.3 branch</a> and document it in the <a href="https://github.com/CrestApps/crestapps-site">CrestApps-site</a> repository. For any help, my email can be found in the `composer.json` file, feel free to send me an email.
131132
- Please start by *Staring* this package on GitHub.
132133
- Sharing this projects with others is your way of saying keep the improvements and new awesome features coming.
133134
- Report any bugs or send us any comments, idea, thought that you may have about this project as an issue on GitHub.

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.2.12",
5+
"version": "v2.2.13",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

src/Commands/Bases/MigrationCommandBase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace CrestApps\CodeGenerator\Commands\Bases;
44

55
use CrestApps\CodeGenerator\Traits\Migration;
6+
use CrestApps\CodeGenerator\Support\Helpers;
67
use Illuminate\Console\Command;
78

89
class MigrationCommandBase extends Command
@@ -20,4 +21,13 @@ public function __construct()
2021

2122
$this->setMigrator();
2223
}
24+
25+
protected function getMigratorNotes()
26+
{
27+
if(Helpers::isNewerThanOrEqualTo('5.7')) {
28+
return $this->migrator->setOutput($this->output);
29+
}
30+
31+
return $this->migrator->getNotes();
32+
}
2333
}

src/Commands/CreateControllerCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,11 @@ protected function getCommandInput()
379379
return (object) compact(
380380
'formRequestDirectory',
381381
'viewDirectory',
382-
'viewName',
383382
'modelName',
384383
'prefix',
385384
'perPage',
386-
'fileSnippet',
387385
'modelDirectory',
388386
'langFile',
389-
'fields',
390387
'withFormRequest',
391388
'formRequestName',
392389
'force',

src/Commands/CreateModelCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected function getNamespace($modelName, $modelDirectory)
163163
*
164164
* @return string
165165
*/
166-
protected function getPrimaryKeyName(Field $primaryField, $primaryKey)
166+
protected function getPrimaryKeyName(Field $primaryField = null, $primaryKey = 'id')
167167
{
168168
return !is_null($primaryField) ? $primaryField->name : $primaryKey;
169169
}

src/Commands/Migrations/MigrateAllCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public function handle()
4949
'pretend' => $this->option('pretend'),
5050
'step' => $this->option('step'),
5151
]);
52-
52+
5353
// Once the migrator has run we will grab the note output and send it out to
5454
// the console screen, since the migrator itself functions without having
5555
// any instances of the OutputInterface contract passed into the class.
56-
foreach ($this->migrator->getNotes() as $note) {
56+
foreach ($this->getMigratorNotes() as $note) {
5757
$this->output->writeln($note);
5858
}
5959

@@ -64,7 +64,7 @@ public function handle()
6464
$this->call('db:seed', ['--force' => true]);
6565
}
6666
}
67-
67+
6868
/**
6969
* Prepare the migration database for running.
7070
*

src/Commands/Migrations/ResetAllCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function handle()
5252
// Once the migrator has run we will grab the note output and send it out to
5353
// the console screen, since the migrator itself functions without having
5454
// any instances of the OutputInterface contract passed into the class.
55-
foreach ($this->migrator->getNotes() as $note) {
55+
foreach ($this->getMigratorNotes() as $note) {
5656
$this->output->writeln($note);
5757
}
5858
}

src/Commands/Migrations/RollbackAllCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle()
4848
// Once the migrator has run we will grab the note output and send it out to
4949
// the console screen, since the migrator itself functions without having
5050
// any instances of the OutputInterface contract passed into the class.
51-
foreach ($this->migrator->getNotes() as $note) {
51+
foreach ($this->getMigratorNotes() as $note) {
5252
$this->output->writeln($note);
5353
}
5454
}

src/Commands/ResourceFileCreateCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public function handle()
6161
}
6262

6363
$fields = FieldTransformer::fromString($this->option('fields'), 'generic', $input->translationFor);
64+
6465
$relations = $this->getRelations($input->relations);
6566
$indexes = $this->getIndexes($input->indexes);
6667

6768
$resource = new Resource($fields, $relations, $indexes);
69+
6870

6971
$this->createFile($file, Helpers::prettifyJson($resource->toArray()))
7072
->info('The "' . basename($file) . '" file was crafted successfully!');

src/Models/Field.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ public function toArray()
882882
'is-unique' => $this->isUnique,
883883
'is-primary' => $this->isPrimary,
884884
'comment' => $this->comment,
885-
'is-nullable' => $this->isNullable,
885+
'is-nullable' => $this->isNullable(),
886886
'is-header' => $this->isHeader,
887887
'is-unsigned' => $this->isUnsigned,
888888
'is-auto-increment' => $this->isAutoIncrement,
@@ -1141,7 +1141,7 @@ public function setValidationProperty(array $properties)
11411141
$this->validationRules = is_array($properties['validation']) ? $properties['validation'] : Helpers::removeEmptyItems(explode('|', $properties['validation']));
11421142
}
11431143

1144-
if (Helpers::isNewerThanOrEqualTo('5.2') && $this->isNullable && !in_array('nullable', $this->validationRules)) {
1144+
if (Helpers::isNewerThanOrEqualTo('5.2') && $this->isNullable() && !in_array('nullable', $this->validationRules)) {
11451145
$this->validationRules[] = 'nullable';
11461146
}
11471147

@@ -1525,7 +1525,7 @@ public function getDecimalPointLength()
15251525
*/
15261526
public function getMinLength()
15271527
{
1528-
if ($this->isRequired() || !$this->isNullable) {
1528+
if ($this->isRequired() || !$this->isNullable()) {
15291529
return 1;
15301530
}
15311531

@@ -1807,15 +1807,15 @@ public static function fromArray(array $properties, $localeGroup)
18071807
->setPlaceholder($properties) // this must come after setForeignRelation
18081808
->setOnStore($properties)
18091809
->setOnUpdate($properties);
1810-
1810+
18111811
if (Field::isValidSelectRangeType($properties)) {
18121812
$field->htmlType = 'selectRange';
18131813
}
18141814

18151815
if ($field->getEloquentDataMethod() == 'enum' && empty($field->getOptions())) {
18161816
throw new Exception('To construct an enum data-type field, options must be set. ' . $field->name);
18171817
}
1818-
1818+
18191819
return $field;
18201820
}
18211821
}

0 commit comments

Comments
 (0)