Skip to content

Commit ab59405

Browse files
committed
Fix #97, #98, 101, 102
1 parent bf85e7f commit ab59405

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Checkout our channel on <a href="https://www.youtube.com/channel/UCkEd0nOoRf3o0a
135135
136136
## Contribution
137137
Do you like this project and want to contribute?
138-
- Please start by *Staring* this package on GitHub.
138+
- **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.
139+
- Please start by ***Staring*** this package on GitHub.
139140
- Sharing this projects with others is your way of saying keep improvements and new awesome feature coming.
140141
- Report any bugs or send us any comments, idea, thought that you may have about this project as an issue on GitHub.
141142

src/Support/FieldOptimizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ protected function optimizeBoolean()
209209
protected function optimizePrimaryKey()
210210
{
211211
if ($this->field->isPrimary()) {
212-
213212
$this->field->isNullable = false;
214213

215214
if ($this->meta == null) {

src/Support/FieldTransformer.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,24 @@ public static function fromString($str, $localeGroup = 'generic', array $languag
9292
if (str_contains($fieldName, ':')) {
9393
// Handle the following format
9494
// name:a;html-type:select;options:first|second|third|fourth
95-
if (!str_is('*name*:*', $fieldName)) {
95+
if (!Str::is('*name*:*', $fieldName)) {
9696
throw new Exception('The "name" property was not provided and is required!');
9797
}
9898

9999
$parts = Arr::fromString($fieldName, ';');
100100

101101
foreach ($parts as $part) {
102-
if (!str_is('*:*', $part) || count($properties = Arr::fromString($part, ':')) < 2) {
102+
if (!Str::is('*:*', $part) || count($properties = Arr::fromString($part, ':')) < 2) {
103103
throw new Exception('Each provided property should use the following format "key:value"');
104104
}
105105
list($key, $value) = $properties;
106+
107+
if(Str::startsWith($key, 'is-')){
108+
$field[$key] = Str::stringToBool($value);
109+
} else {
110+
$field[$key] = $value;
111+
}
112+
106113
$field[$key] = $value;
107114
if ($key == 'options') {
108115
$options = Arr::fromString($value, '|');

src/Support/Str.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,22 @@ public static function trimStart($subject, $search)
126126

127127
return $subject;
128128
}
129-
129+
130+
/**
131+
* Check a string for a positive keyword
132+
*
133+
* @param string $str
134+
*
135+
* @return array
136+
*/
137+
public static function stringToBool($str)
138+
{
139+
if (is_bool($str)) {
140+
return $str;
141+
}
142+
return in_array(strtolower($str), ['true', 'yes', '1', 'valid', 'correct']);
143+
}
144+
130145
/**
131146
* Checks if a string matches at least one given pattern
132147
*

0 commit comments

Comments
 (0)