Skip to content

Commit 594f011

Browse files
authored
Merge branch 'master' into 217-available-relations
2 parents 848c312 + 508fa3d commit 594f011

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

src/Commands/MakeEntityCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ protected function convertToPascalCase(string $entityName): string
313313
$pascalEntityName = Str::studly($entityName);
314314

315315
if ($entityName !== $pascalEntityName) {
316-
$this->info("{$entityName} was converted to {$pascalEntityName}");
316+
$this->warn("{$entityName} was converted to {$pascalEntityName}");
317317
}
318318

319319
return $pascalEntityName;

src/Generators/RequestsGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ protected function getSearchValidationParameters(): array
136136
'per_page',
137137
]);
138138

139-
$parameters['array'] = ['with'];
140-
141139
$parameters['string'] = ['order_by'];
142140

143141
$parameters['string-nullable'] = ['query'];
144142

143+
$parameters['array'] = ['with'];
144+
145145
$parameters['string-required'] = ['with.*'];
146146

147-
return $this->getValidationParameters($parameters, false);
147+
return $this->getValidationParameters($parameters, true);
148148
}
149149

150150
public function getValidationParameters($parameters, $requiredAvailable): array
@@ -188,7 +188,7 @@ protected function getRules($name, $type, $required, $nullable, $present): array
188188
}
189189

190190
if ($required) {
191-
$rules[] = 'required';
191+
array_unshift($rules, 'required');
192192
}
193193

194194
if ($nullable) {

tests/fixtures/CommandTest/get_request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function rules(): array
1414

1515
return [
1616
'with' => 'array',
17-
'with.*' => 'string|required|in:' . $availableRelations,
17+
'with.*' => 'required|string|in:' . $availableRelations,
1818
];
1919
}
2020

tests/fixtures/CommandTest/search_request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public function rules(): array
1717
'order_by' => 'string|in:' . $this->getOrderableFields(Post::class),
1818
'desc' => 'boolean',
1919
'all' => 'boolean',
20-
'with' => 'array',
2120
'query' => 'string|nullable',
22-
'with.*' => 'string|in:' . $availableRelations,
21+
'with' => 'array',
22+
'with.*' => 'required|string|in:' . $availableRelations,
2323
];
2424
}
2525

tests/fixtures/CommandTest/search_request_subfolder_model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public function rules(): array
1717
'order_by' => 'string|in:' . $this->getOrderableFields(Post::class),
1818
'desc' => 'boolean',
1919
'all' => 'boolean',
20-
'with' => 'array',
2120
'query' => 'string|nullable',
22-
'with.*' => 'string|in:' . $availableRelations,
21+
'with' => 'array',
22+
'with.*' => 'required|string|in:' . $availableRelations,
2323
];
2424
}
2525

tests/fixtures/RequestGeneratorTest/create_request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CreatePostRequest extends Request
99
public function rules(): array
1010
{
1111
return [
12-
'user_id' => 'integer|exists:users,id|required',
12+
'user_id' => 'required|integer|exists:users,id',
1313
'is_draft' => 'boolean',
1414
'is_published' => 'boolean|present',
1515
];

tests/fixtures/RequestGeneratorTest/get_request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function rules(): array
1414

1515
return [
1616
'with' => 'array',
17-
'with.*' => 'string|required|in:' . $availableRelations,
17+
'with.*' => 'required|string|in:' . $availableRelations,
1818
];
1919
}
2020

tests/fixtures/RequestGeneratorTest/search_request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ public function rules(): array
1212
$availableRelations = implode(',', $this->getAvailableRelations());
1313

1414
return [
15-
'user_id' => 'integer|exists:users,id|required',
15+
'user_id' => 'required|integer|exists:users,id',
1616
'page' => 'integer',
1717
'per_page' => 'integer',
1818
'is_published' => 'boolean',
1919
'desc' => 'boolean',
2020
'all' => 'boolean',
21-
'with' => 'array',
2221
'order_by' => 'string|in:' . $this->getOrderableFields(Post::class),
2322
'query' => 'string|nullable',
24-
'with.*' => 'string|in:' . $availableRelations,
23+
'with' => 'array',
24+
'with.*' => 'required|string|in:' . $availableRelations,
2525
];
2626
}
2727

tests/fixtures/RequestGeneratorTest/update_request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class UpdatePostRequest extends Request
1111
public function rules(): array
1212
{
1313
return [
14-
'user_id' => 'integer|exists:users,id|required',
14+
'user_id' => 'required|integer|exists:users,id',
1515
'is_draft' => 'boolean',
1616
'is_published' => 'boolean',
1717
];

0 commit comments

Comments
 (0)