@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param null $default |
| 21 | 21 | * @return mixed |
| 22 | 22 | */ |
| 23 | - public function input($key, $default=null); |
|
| 23 | + public function input($key, $default = null); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @param $key |
@@ -45,5 +45,5 @@ discard block |
||
| 45 | 45 | * @param $value |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | - public function set($key,$value); |
|
| 48 | + public function set($key, $value); |
|
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function handle() |
| 24 | 24 | { |
| 25 | - foreach ($this->tableFilters() as $table=>$files){ |
|
| 25 | + foreach ($this->tableFilters() as $table=>$files) { |
|
| 26 | 26 | |
| 27 | 27 | $table = strtolower($table); |
| 28 | 28 | |
@@ -30,20 +30,20 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $checkMigrationMain = $this->schema->getConnection()->checkMigrationMain(); |
| 32 | 32 | |
| 33 | - if($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])){ |
|
| 34 | - $this->apply($this->tableFilters()['Migrations'][0],'migrations'); |
|
| 33 | + if ($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])) { |
|
| 34 | + $this->apply($this->tableFilters()['Migrations'][0], 'migrations'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $checkMigration = $this->schema->getConnection()->checkMigration($table,$file); |
|
| 37 | + $checkMigration = $this->schema->getConnection()->checkMigration($table, $file); |
|
| 38 | 38 | |
| 39 | - if(!$checkMigration){ |
|
| 39 | + if (!$checkMigration) { |
|
| 40 | 40 | |
| 41 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 41 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 42 | 42 | $className = $this->getClassName($getClassName); |
| 43 | 43 | |
| 44 | 44 | require_once ($file); |
| 45 | 45 | |
| 46 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 46 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 47 | 47 | |
| 48 | 48 | $this->list[$table][] = (new $className)->up($capsule); |
| 49 | 49 | } |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | * @param $table |
| 61 | 61 | * @return mixed|string |
| 62 | 62 | */ |
| 63 | - public function apply($file,$table) |
|
| 63 | + public function apply($file, $table) |
|
| 64 | 64 | { |
| 65 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 65 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 66 | 66 | $className = $this->getClassName($getClassName); |
| 67 | 67 | |
| 68 | 68 | require_once ($file); |
| 69 | 69 | |
| 70 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 70 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 71 | 71 | |
| 72 | 72 | $this->list[$table][] = (new $className)->up($capsule); |
| 73 | 73 | |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | * @param $name |
| 11 | 11 | * @return string |
| 12 | 12 | */ |
| 13 | - protected function getNullableValue($nullable,$name) |
|
| 13 | + protected function getNullableValue($nullable, $name) |
|
| 14 | 14 | { |
| 15 | - $nullableValue=''; |
|
| 15 | + $nullableValue = ''; |
|
| 16 | 16 | |
| 17 | - if(isset($nullable[$name])){ |
|
| 18 | - if($nullable[$name]===false){ |
|
| 19 | - $nullableValue='NOT NULL'; |
|
| 17 | + if (isset($nullable[$name])) { |
|
| 18 | + if ($nullable[$name]===false) { |
|
| 19 | + $nullableValue = 'NOT NULL'; |
|
| 20 | 20 | } |
| 21 | - else{ |
|
| 22 | - $nullableValue='NULL'; |
|
| 21 | + else { |
|
| 22 | + $nullableValue = 'NULL'; |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
@@ -59,22 +59,22 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | protected function getValueWithIsset($name) |
| 61 | 61 | { |
| 62 | - $nameKey = array_search($name,$this->data['names']); |
|
| 62 | + $nameKey = array_search($name, $this->data['names']); |
|
| 63 | 63 | |
| 64 | 64 | $list = []; |
| 65 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
| 65 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
| 66 | 66 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
| 67 | 67 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
| 68 | 68 | |
| 69 | - if(isset($this->data['types'][$nameKey])){ |
|
| 70 | - if($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])){ |
|
| 69 | + if (isset($this->data['types'][$nameKey])) { |
|
| 70 | + if ($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])) { |
|
| 71 | 71 | $this->data['default'][$name] = 'CURRENT_TIMESTAMP'; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if($this->data['types'][$nameKey]!=='timestamp'){ |
|
| 74 | + if ($this->data['types'][$nameKey]!=='timestamp') { |
|
| 75 | 75 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
| 76 | 76 | } |
| 77 | - else{ |
|
| 77 | + else { |
|
| 78 | 78 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(count($list)===3){ |
|
| 85 | + if (count($list)===3) { |
|
| 86 | 86 | $list[] = ''; |
| 87 | 87 | $list[] = ''; |
| 88 | 88 | } |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | protected function getUniqueValueList($name) |
| 100 | 100 | { |
| 101 | 101 | //get unique |
| 102 | - if(isset($this->data['unique'][$name])){ |
|
| 103 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
| 102 | + if (isset($this->data['unique'][$name])) { |
|
| 103 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | protected function getIndexValueList($name) |
| 111 | 111 | { |
| 112 | 112 | //get index |
| 113 | - if(isset($this->data['index'][$name])){ |
|
| 114 | - $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
| 113 | + if (isset($this->data['index'][$name])) { |
|
| 114 | + $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function getCreateDefaultList() |
| 134 | 134 | { |
| 135 | - $list = []; |
|
| 135 | + $list = []; |
|
| 136 | 136 | |
| 137 | 137 | foreach ($this->data['names'] as $key=>$name) |
| 138 | 138 | { |
| 139 | 139 | list( |
| 140 | - $nullableValue,$autoIncrementValue, |
|
| 141 | - $primaryKeyValue,$defaultValue,$commentValue |
|
| 140 | + $nullableValue, $autoIncrementValue, |
|
| 141 | + $primaryKeyValue, $defaultValue, $commentValue |
|
| 142 | 142 | ) = $this->getValueWithIsset($name); |
| 143 | 143 | |
| 144 | 144 | //set index values |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $types = (isset($this->data['types'][$key])) ? $this->data['types'][$key] : ''; |
| 148 | 148 | |
| 149 | - $list[]=''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
| 149 | + $list[] = ''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $list; |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function getKeyList() |
| 159 | 159 | { |
| 160 | - $keyList = []; |
|
| 160 | + $keyList = []; |
|
| 161 | 161 | |
| 162 | 162 | //multiple indexes |
| 163 | - if(isset($this->data['index']['indexes'])){ |
|
| 163 | + if (isset($this->data['index']['indexes'])) { |
|
| 164 | 164 | |
| 165 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
| 165 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
| 166 | 166 | |
| 167 | 167 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
| 168 | 168 | |
| 169 | 169 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
| 170 | 170 | |
| 171 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
| 171 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -183,13 +183,13 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $list = []; |
| 185 | 185 | |
| 186 | - foreach ($reference as $constraint=>$values){ |
|
| 186 | + foreach ($reference as $constraint=>$values) { |
|
| 187 | 187 | |
| 188 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
| 188 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
| 189 | 189 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return implode (" ",$list); |
|
| 192 | + return implode(" ", $list); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | private function getOnProcess($referenceValue) |
| 199 | 199 | { |
| 200 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
| 200 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
| 201 | 201 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | if(isset($nullable[$name])){ |
| 18 | 18 | if($nullable[$name]===false){ |
| 19 | 19 | $nullableValue='NOT NULL'; |
| 20 | - } |
|
| 21 | - else{ |
|
| 20 | + } else{ |
|
| 22 | 21 | $nullableValue='NULL'; |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | |
| 74 | 73 | if($this->data['types'][$nameKey]!=='timestamp'){ |
| 75 | 74 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
| 76 | - } |
|
| 77 | - else{ |
|
| 75 | + } else{ |
|
| 78 | 76 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
| 79 | 77 | } |
| 80 | 78 | |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | * @param array $uniques |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function uniques($unique_name,$uniques=array()); |
|
| 12 | + public function uniques($unique_name, $uniques = array()); |
|
| 13 | 13 | } |
| 14 | 14 | |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | * @param array $indexes |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function indexes($index_name,$indexes=array()); |
|
| 12 | + public function indexes($index_name, $indexes = array()); |
|
| 13 | 13 | } |
| 14 | 14 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | private function getWizardAlterInstance($group) |
| 92 | 92 | { |
| 93 | - $this->setAlterType('group',$group); |
|
| 93 | + $this->setAlterType('group', $group); |
|
| 94 | 94 | |
| 95 | 95 | return new WizardAlter($this); |
| 96 | 96 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function dropWizardAlterInstance($group) |
| 103 | 103 | { |
| 104 | - $this->setAlterType('group',$group); |
|
| 104 | + $this->setAlterType('group', $group); |
|
| 105 | 105 | |
| 106 | 106 | return $this; |
| 107 | 107 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function dropKeyWizardAlterInstance($group) |
| 114 | 114 | { |
| 115 | - $this->setAlterType('group',$group); |
|
| 115 | + $this->setAlterType('group', $group); |
|
| 116 | 116 | |
| 117 | 117 | return $this; |
| 118 | 118 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | private function addIndexWizardAlterInstance($group) |
| 125 | 125 | { |
| 126 | - $this->setAlterType('group',$group); |
|
| 126 | + $this->setAlterType('group', $group); |
|
| 127 | 127 | |
| 128 | 128 | return $this; |
| 129 | 129 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function addUniqueWizardAlterInstance($group) |
| 136 | 136 | { |
| 137 | - $this->setAlterType('group',$group); |
|
| 137 | + $this->setAlterType('group', $group); |
|
| 138 | 138 | |
| 139 | 139 | return $this; |
| 140 | 140 | } |
@@ -14,44 +14,44 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function processHandler() |
| 16 | 16 | { |
| 17 | - return $this->errorHandler(function(){ |
|
| 17 | + return $this->errorHandler(function() { |
|
| 18 | 18 | |
| 19 | 19 | $results = []; |
| 20 | 20 | |
| 21 | - foreach ($this->list as $table =>$datas){ |
|
| 21 | + foreach ($this->list as $table =>$datas) { |
|
| 22 | 22 | |
| 23 | - foreach ($datas as $data){ |
|
| 23 | + foreach ($datas as $data) { |
|
| 24 | 24 | |
| 25 | - $query = $this->queryBuilder($table,$data); |
|
| 25 | + $query = $this->queryBuilder($table, $data); |
|
| 26 | 26 | |
| 27 | 27 | $query = $query->handle(); |
| 28 | 28 | |
| 29 | - if($query===false){ |
|
| 29 | + if ($query===false) { |
|
| 30 | 30 | $results[] = []; |
| 31 | 31 | } |
| 32 | - else{ |
|
| 33 | - $status =($query['result']!==false) ? true : false; |
|
| 32 | + else { |
|
| 33 | + $status = ($query['result']!==false) ? true : false; |
|
| 34 | 34 | |
| 35 | - if($status){ |
|
| 35 | + if ($status) { |
|
| 36 | 36 | |
| 37 | - $this->schema->getConnection()->registerMigration($table,$data->getFile()); |
|
| 37 | + $this->schema->getConnection()->registerMigration($table, $data->getFile()); |
|
| 38 | 38 | |
| 39 | - if(app()->isLocale()){ |
|
| 39 | + if (app()->isLocale()) { |
|
| 40 | 40 | |
| 41 | 41 | $this->schema->getConnection()->generateEntity($table); |
| 42 | 42 | |
| 43 | - if(substr($table,-1)=='s'){ |
|
| 44 | - app()->command('model create','model:'.strtolower(substr($table,0,-1)).' table:'.$table.' entity:'.$table); |
|
| 43 | + if (substr($table, -1)=='s') { |
|
| 44 | + app()->command('model create', 'model:'.strtolower(substr($table, 0, -1)).' table:'.$table.' entity:'.$table); |
|
| 45 | 45 | } |
| 46 | - else{ |
|
| 47 | - app()->command('model create','model:'.strtolower($table).' table:'.$table.' entity:'.$table); |
|
| 46 | + else { |
|
| 47 | + app()->command('model create', 'model:'.strtolower($table).' table:'.$table.' entity:'.$table); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $results[]= [ |
|
| 54 | + $results[] = [ |
|
| 55 | 55 | 'success'=>$status, |
| 56 | 56 | 'file'=>$data->getFile(), |
| 57 | 57 | 'table'=>$table, |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $alterBinds = $object->getAlterBinds(); |
| 83 | 83 | |
| 84 | - if(!is_null($alterBinds) && count($alterBinds)>1){ |
|
| 84 | + if (!is_null($alterBinds) && count($alterBinds)>1) { |
|
| 85 | 85 | exception()->runtime('Only one command can be applied to alter groups'); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if(count($object->getError())){ |
|
| 88 | + if (count($object->getError())) { |
|
| 89 | 89 | exception()->runtime(''.$object->getFile().' -> '.$object->getError()[0].''); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | if($query===false){ |
| 30 | 30 | $results[] = []; |
| 31 | - } |
|
| 32 | - else{ |
|
| 31 | + } else{ |
|
| 33 | 32 | $status =($query['result']!==false) ? true : false; |
| 34 | 33 | |
| 35 | 34 | if($status){ |
@@ -42,8 +41,7 @@ discard block |
||
| 42 | 41 | |
| 43 | 42 | if(substr($table,-1)=='s'){ |
| 44 | 43 | app()->command('model create','model:'.strtolower(substr($table,0,-1)).' table:'.$table.' entity:'.$table); |
| 45 | - } |
|
| 46 | - else{ |
|
| 44 | + } else{ |
|
| 47 | 45 | app()->command('model create','model:'.strtolower($table).' table:'.$table.' entity:'.$table); |
| 48 | 46 | } |
| 49 | 47 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public static function permissionMake($routeName) |
| 18 | 18 | {
|
| 19 | - $permission = static::where('route_name',$routeName)->where('role_id',auth()->user()->role_id);
|
|
| 19 | + $permission = static::where('route_name', $routeName)->where('role_id', auth()->user()->role_id);
|
|
| 20 | 20 | |
| 21 | 21 | return ($permission->count()) ? true : false; |
| 22 | 22 | } |
@@ -16,17 +16,17 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public static function roleMake($role) |
| 18 | 18 | {
|
| 19 | - $roleCriteria = explode(':',$role);
|
|
| 19 | + $roleCriteria = explode(':', $role);
|
|
| 20 | 20 | |
| 21 | - if(isset($roleCriteria[1])){
|
|
| 22 | - $role = static::where('name',$roleCriteria[0])->
|
|
| 23 | - where('status',1)->where('is_deleted',0)->where('role_state',$roleCriteria[1])->first();
|
|
| 21 | + if (isset($roleCriteria[1])) {
|
|
| 22 | + $role = static::where('name', $roleCriteria[0])->
|
|
| 23 | + where('status', 1)->where('is_deleted', 0)->where('role_state', $roleCriteria[1])->first();
|
|
| 24 | 24 | |
| 25 | - if(is_null($role)){
|
|
| 25 | + if (is_null($role)) {
|
|
| 26 | 26 | exception('roleDefinitorException')->runtime('roleDefinitorException');
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if(auth()->user()->role_id == $role->id){
|
|
| 29 | + if (auth()->user()->role_id==$role->id) {
|
|
| 30 | 30 | return true; |
| 31 | 31 | } |
| 32 | 32 | |