Skip to content

Commit c3a28b2

Browse files
committed
Fix #108, #109, and #110
1 parent ab59405 commit c3a28b2

File tree

7 files changed

+29
-11
lines changed

7 files changed

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

src/Commands/Api/CreateApiScaffoldCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CreateApiScaffoldCommand extends CreateScaffoldCommandBase
2626
{--controller-directory= : The directory where the controller should be created under. }
2727
{--controller-extends=default-controller : The base controller to be extend.}
2828
{--model-directory= : The path of the model.}
29-
{--views-directory= : The name of the view path.}
29+
{--model-extends=default-model : The base model to be extend.}
3030
{--form-request-directory= : The directory of the form-request.}
3131
{--resource-file= : The name of the resource-file to import from.}
3232
{--fields= : If the resource-file does not exists, passing list of fields here will create it first.}
@@ -114,7 +114,7 @@ protected function createController(ApiScaffoldInput $input)
114114
'--models-per-page' => $input->perPage,
115115
'--routes-prefix' => $input->prefix,
116116
'--language-filename' => $input->languageFileName,
117-
'--with-form-request' => $input->formRequest,
117+
'--with-form-request' => $input->withFormRequest,
118118
'--without-form-request' => $this->option('without-form-request'),
119119
'--form-request-directory' => $input->formRequestDirectory,
120120
'--with-auth' => $input->withAuth,

src/Commands/Bases/CreateScaffoldCommandBase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ protected function getCommandInput()
210210
$input->withoutModel = $this->option('without-model');
211211
$input->withoutController = $this->option('without-controller');
212212
$input->withoutFormRequest = $this->option('without-form-request');
213-
$input->withoutViews = $this->option('without-views');
214213
$input->migrationClass = $this->option('migration-class-name');
215214
$input->connectionName = $this->option('connection-name');
216215
$input->engineName = $this->option('engine-name');

src/Commands/Framework/CreateScaffoldCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ protected function getCommandInput()
179179
$input = new ScaffoldInput(parent::getCommandInput());
180180

181181
$input->viewsDirectory = trim($this->option('views-directory'));
182+
$input->withoutViews = $this->option('without-views');
183+
182184
$input->layoutName = $this->option('layout-name') ?: 'layouts.app';
183185

184186
return $input;

src/Models/Field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ public function getOnAction($action)
11401140
*/
11411141
public function setDataTypeParams(array $properties)
11421142
{
1143-
if (Arr::isKeyExists($properties, 'data-type-params') && is_array($properties['data-type-params'])) {
1143+
if (Arr::isKeyExists($properties, 'data-type-params')) {
11441144
$this->methodParams = $this->getDataTypeParams((array) $properties['data-type-params']);
11451145
}
11461146

src/Models/ForeignRelationship.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ForeignRelationship implements JsonWriter
6767
public function __construct($type, $parameters, $name, $field = null)
6868
{
6969
$this->setType($type);
70-
$this->setParameters((array) $parameters);
70+
$this->setParameters($parameters);
7171
$this->name = $name;
7272
$this->setField($field);
7373
}
@@ -77,10 +77,16 @@ public function __construct($type, $parameters, $name, $field = null)
7777
*
7878
* @return void
7979
*/
80-
public function setParameters(array $parameters)
80+
public function setParameters($parameters)
8181
{
8282
$this->parameters = [];
8383

84+
$this->parameters = [];
85+
86+
if(!is_array($parameters)){
87+
$parameters = Arr::fromString($parameters, '|');
88+
}
89+
8490
foreach ($parameters as $parameter) {
8591
$this->parameters[] = Str::eliminateDupilcates($parameter, "\\");
8692
}
@@ -424,8 +430,19 @@ public function toArray()
424430
public static function get(array $options)
425431
{
426432
if (!self::isValid($options)) {
427-
return null;
428-
}
433+
if(count($options) >= 3) {
434+
$values = array_values($options);
435+
$field = isset($values[3]) ? $values[3] : null;
436+
return new ForeignRelationship(
437+
$values[1],
438+
$values[2],
439+
$values[0],
440+
$field
441+
);
442+
}
443+
444+
return null;
445+
}
429446

430447
$field = array_key_exists('field', $options) ? $options['field'] : null;
431448

src/Support/Arr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public static function wrapItems(array $items, $wrapper = "'")
4545
*
4646
* @return array
4747
*/
48-
public static function fromString($str, $seperator = ',')
48+
public static function fromString($str, $seperator = ',', $limit = PHP_INT_MAX)
4949
{
50-
return self::removeEmptyItems(explode($seperator, $str), function ($param) {
50+
return self::removeEmptyItems(explode($seperator, $str, $limit ), function ($param) {
5151
return Str::trimQuots($param);
5252
});
5353
}

0 commit comments

Comments
 (0)