@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | $data = new TypeResolver($this->name, $column, $typeOptions); |
46 | 46 | $type = $data->getLaragenType(); |
47 | 47 | $this->columnsData[$column] = $type; |
48 | - if($type->isDisplay()) |
|
48 | + if ($type->isDisplay()) |
|
49 | 49 | $this->displayColumns[] = $type; |
50 | 50 | } |
51 | 51 | |
52 | - if(sizeof($this->displayColumns)==0){ |
|
52 | + if (sizeof($this->displayColumns) == 0) { |
|
53 | 53 | $this->displayColumns[] = array_values($this->columnsData)[0]; |
54 | 54 | } |
55 | 55 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | public function getPivotalColumns() |
112 | 112 | { |
113 | 113 | $relativeTypes = []; |
114 | - foreach($this->columnsData as $type){ |
|
115 | - if($type->isRelational()&&$type->hasPivot()){ |
|
114 | + foreach ($this->columnsData as $type) { |
|
115 | + if ($type->isRelational() && $type->hasPivot()) { |
|
116 | 116 | $relativeTypes[] = $type; |
117 | 117 | } |
118 | 118 | } |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | { |
124 | 124 | $filteredTypes = []; |
125 | 125 | $options = is_array($options) ? $options : [$options]; |
126 | - foreach($this->columnsData as $type){ |
|
126 | + foreach ($this->columnsData as $type) { |
|
127 | 127 | foreach ($options as $option) { |
128 | - if($type->$option()){ |
|
128 | + if ($type->$option()) { |
|
129 | 129 | $filteredTypes[] = $columnsOnly ? $type->getColumn() : $type; |
130 | 130 | break; |
131 | 131 | } |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | public function getColumns($onlyNonRelational = false, $columnsOnly = false) |
138 | 138 | { |
139 | 139 | $columns = []; |
140 | - foreach($this->columnsData as $type){ |
|
141 | - if($onlyNonRelational && $type->isRelational()){ |
|
140 | + foreach ($this->columnsData as $type) { |
|
141 | + if ($onlyNonRelational && $type->isRelational()) { |
|
142 | 142 | continue; |
143 | 143 | } |
144 | - if($columnsOnly){ |
|
144 | + if ($columnsOnly) { |
|
145 | 145 | $columns[] = $type->getColumnKey(); |
146 | - }else{ |
|
146 | + } else { |
|
147 | 147 | $columns[$type->getColumnKey()] = $type; |
148 | 148 | } |
149 | 149 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | public function hasPivotRelations() |
159 | 159 | { |
160 | 160 | $hasRelations = false; |
161 | - foreach($this->columnsData as $column => $type){ |
|
162 | - if($type->isRelational()&&$type->hasPivot()){ |
|
161 | + foreach ($this->columnsData as $column => $type) { |
|
162 | + if ($type->isRelational() && $type->hasPivot()) { |
|
163 | 163 | $hasRelations = true; |
164 | 164 | break; |
165 | 165 | } |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | if (is_dir($src)) { |
14 | 14 | $this->mirror($src, $dest."/".basename($src)); |
15 | - }else{ |
|
15 | + } else { |
|
16 | 16 | $this->copy($src, $dest); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - public function getFullSourcePath($path){ |
|
21 | - return realpath(__DIR__ . "/../resources/" . $path); |
|
20 | + public function getFullSourcePath($path) { |
|
21 | + return realpath(__DIR__."/../resources/".$path); |
|
22 | 22 | } |
23 | 23 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function getFormOptions() { |
12 | 12 | $options = ""; |
13 | 13 | $options .= $this->isRequired() ? 'required="required" ' : ''; |
14 | - $options .='rows="'.$this->getTextRows().'" '; |
|
14 | + $options .= 'rows="'.$this->getTextRows().'" '; |
|
15 | 15 | return $options; |
16 | 16 | } |
17 | 17 |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | |
30 | 30 | public function getPivotTable() |
31 | 31 | { |
32 | - return $this->getParentModelLowercase() . "_" . strtolower(Str::plural($this->columnName)); |
|
32 | + return $this->getParentModelLowercase()."_".strtolower(Str::plural($this->columnName)); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getMigrationPivot() |
36 | 36 | { |
37 | - return $this->getParentModel() . Str::plural($this->getChildModel()); |
|
37 | + return $this->getParentModel().Str::plural($this->getChildModel()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getRelatedModel() |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function getPivot() |
46 | 46 | { |
47 | - return $this->getParentModel() . $this->getChildModel(); |
|
47 | + return $this->getParentModel().$this->getChildModel(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getPivotColumns() |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | $type = explode(':', $typePieces); |
30 | 30 | $this->typeOption = is_array($type) && count($type) >= 2 ? $type[1] : false; |
31 | 31 | |
32 | - if(in_array(TypeResolver::COLUMN_UNIQUE, $this->optionArray)){ |
|
32 | + if (in_array(TypeResolver::COLUMN_UNIQUE, $this->optionArray)) { |
|
33 | 33 | $this->setUnique(); |
34 | 34 | } |
35 | - if(in_array(TypeResolver::COLUMN_REQUIRED, $this->optionArray)){ |
|
35 | + if (in_array(TypeResolver::COLUMN_REQUIRED, $this->optionArray)) { |
|
36 | 36 | $this->setRequired(); |
37 | 37 | } |
38 | - if(in_array("*", $this->optionArray)){ |
|
38 | + if (in_array("*", $this->optionArray)) { |
|
39 | 39 | $this->setIsDisplay(); |
40 | 40 | } |
41 | 41 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | if ($this->isUnique()) { |
83 | 83 | $validationLine = '($this->'.$modelname.') ? \''; |
84 | - $validationLine .= $rules . '|unique:'.$this->moduleName.','.$this->getColumn().','.'\''.'.$this->'.$modelname.'->id : \''; |
|
85 | - $validationLine .= $rules . '|unique:'.$this->moduleName.'\''; |
|
86 | - } else{ |
|
84 | + $validationLine .= $rules.'|unique:'.$this->moduleName.','.$this->getColumn().','.'\''.'.$this->'.$modelname.'->id : \''; |
|
85 | + $validationLine .= $rules.'|unique:'.$this->moduleName.'\''; |
|
86 | + } else { |
|
87 | 87 | $validationLine = "'{$rules}'"; |
88 | 88 | } |
89 | 89 | return $validationLine; |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | |
99 | 99 | public function getForeignKey() |
100 | 100 | { |
101 | - return $this->columnName . "_id"; |
|
101 | + return $this->columnName."_id"; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function getFilteredColumns($options = [], $columnsOnly = false) |
105 | 105 | { |
106 | 106 | $filteredTypes = []; |
107 | 107 | $options = is_array($options) ? $options : [$options]; |
108 | - foreach($this->getPivotColumns() as $type){ |
|
108 | + foreach ($this->getPivotColumns() as $type) { |
|
109 | 109 | foreach ($options as $option) { |
110 | - if($type->$option()){ |
|
110 | + if ($type->$option()) { |
|
111 | 111 | $filteredTypes[] = $columnsOnly ? $type->getColumn() : $type; |
112 | 112 | break; |
113 | 113 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | public function getChildModel() |
135 | 135 | { |
136 | - return ucfirst(Str::camel(Str::singular($this->typeOption ?: $this->columnName ))); |
|
136 | + return ucfirst(Str::camel(Str::singular($this->typeOption ?: $this->columnName))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public function getParentModel() |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function getDbData() |
21 | 21 | { |
22 | - return explode(':',$this->optionArray[0]); |
|
22 | + return explode(':', $this->optionArray[0]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function getPivotSchema() |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | |
37 | 37 | public function getPivotTable() |
38 | 38 | { |
39 | - return $this->getParentModelLowercase() . "_" . Str::plural($this->columnName); |
|
39 | + return $this->getParentModelLowercase()."_".Str::plural($this->columnName); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getMigrationPivot() |
43 | 43 | { |
44 | - return $this->getParentModel() . Str::plural($this->getChildModel()); |
|
44 | + return $this->getParentModel().Str::plural($this->getChildModel()); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function getPivot() |
48 | 48 | { |
49 | - return $this->getParentModel() . $this->getChildModel(); |
|
49 | + return $this->getParentModel().$this->getChildModel(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getTypeColumns() |
@@ -36,17 +36,17 @@ |
||
36 | 36 | |
37 | 37 | public function getPivot() |
38 | 38 | { |
39 | - return $this->getParentModel() . $this->getChildModel(); |
|
39 | + return $this->getParentModel().$this->getChildModel(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getMigrationPivot() |
43 | 43 | { |
44 | - return $this->getParentModel() . Str::plural($this->getChildModel()); |
|
44 | + return $this->getParentModel().Str::plural($this->getChildModel()); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function getPivotTable() |
48 | 48 | { |
49 | - return $this->getParentModelLowercase(). "_" . strtolower(Str::plural($this->columnName)); |
|
49 | + return $this->getParentModelLowercase()."_".strtolower(Str::plural($this->columnName)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getPivotColumns() |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $schema .= '$table->bigInteger("'.$this->getParentKey().'")->unsigned()->nullable();'.PHP_EOL.$this->getTabs(3); |
21 | 21 | $schema .= '$table->foreign("'.$this->getParentKey().'")->references("id")->on("'.$moduleName.'")->onDelete("set null");'.PHP_EOL.$this->getTabs(3); |
22 | 22 | |
23 | - $schema .= '$table->bigInteger("'. $this->getChildKey() .'")->unsigned()->nullable();'.PHP_EOL.$this->getTabs(3); |
|
23 | + $schema .= '$table->bigInteger("'.$this->getChildKey().'")->unsigned()->nullable();'.PHP_EOL.$this->getTabs(3); |
|
24 | 24 | $schema .= '$table->foreign("'.$this->getChildKey().'")->references("id")->on("'.$this->typeOption.'")->onDelete("set null");'.PHP_EOL; |
25 | 25 | |
26 | 26 | return $schema; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getChildKey() |
45 | 45 | { |
46 | - return Str::singular($this->columnName) ."_id"; |
|
46 | + return Str::singular($this->columnName)."_id"; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getChildModel() |
@@ -89,6 +89,6 @@ discard block |
||
89 | 89 | |
90 | 90 | public function getTypeColumns() |
91 | 91 | { |
92 | - return [$this->getParentModelLowercase().'_id', strtolower(Str::singular($this->typeOption)) . '_id']; |
|
92 | + return [$this->getParentModelLowercase().'_id', strtolower(Str::singular($this->typeOption)).'_id']; |
|
93 | 93 | } |
94 | 94 | } |
@@ -20,13 +20,13 @@ |
||
20 | 20 | return 'exists:'.$this->getRelatedModule().',id'; |
21 | 21 | } |
22 | 22 | |
23 | - public function hasSelfParent(){ |
|
23 | + public function hasSelfParent() { |
|
24 | 24 | return ($this->typeOption == $this->getParentModule() || $this->typeOption == "self"); |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function getColumnKey() |
28 | 28 | { |
29 | - return $this->columnName . "_id"; |
|
29 | + return $this->columnName."_id"; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | } |