| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | <?php namespace Wn\Generators\Commands; | 
| 2 | 2 | |
| 3 | 3 | |
| 4 | -use InvalidArgumentException; | |
| 5 | 4 | use Illuminate\Support\Str; | 
| 6 | 5 | |
| 7 | 6 |  class ResourceCommand extends BaseCommand { | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | ]); | 
| 63 | 63 | |
| 64 | 64 | // generating REST actions trait if doesn't exist | 
| 65 | -        if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){ | |
| 65 | +        if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) { | |
| 66 | 66 |              $this->call('wn:controller:rest-actions'); | 
| 67 | 67 | } | 
| 68 | 68 | // generating the controller and routes | 
| @@ -94,10 +94,10 @@ discard block | ||
| 94 | 94 | protected function parseFields() | 
| 95 | 95 |      { | 
| 96 | 96 |          $fields = $this->argument('fields'); | 
| 97 | -        if($this->option('parsed')){ | |
| 97 | +        if ($this->option('parsed')) { | |
| 98 | 98 | $this->fields = $fields; | 
| 99 | 99 |          } else { | 
| 100 | -            if(! $fields){ | |
| 100 | +            if (!$fields) { | |
| 101 | 101 | $this->fields = []; | 
| 102 | 102 |              } else { | 
| 103 | 103 |                  $this->fields = $this->getArgumentParser('fields') | 
| @@ -121,7 +121,7 @@ discard block | ||
| 121 | 121 | |
| 122 | 122 | protected function fieldsHavingTag($tag) | 
| 123 | 123 |      { | 
| 124 | -        return array_map(function($field){ | |
| 124 | +        return array_map(function($field) { | |
| 125 | 125 | return $field['name']; | 
| 126 | 126 |          }, array_filter($this->fields, function($field) use($tag){ | 
| 127 | 127 | return in_array($tag, $field['tags']); | 
| @@ -130,19 +130,19 @@ discard block | ||
| 130 | 130 | |
| 131 | 131 | protected function rules() | 
| 132 | 132 |      { | 
| 133 | -        return array_map(function($field){ | |
| 133 | +        return array_map(function($field) { | |
| 134 | 134 | return [ | 
| 135 | 135 | 'name' => $field['name'], | 
| 136 | 136 | 'rule' => $field['rules'] | 
| 137 | 137 | ]; | 
| 138 | -        }, array_filter($this->fields, function($field){ | |
| 138 | +        }, array_filter($this->fields, function($field) { | |
| 139 | 139 | return !empty($field['rules']); | 
| 140 | 140 | })); | 
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 | protected function schema() | 
| 144 | 144 |      { | 
| 145 | -        return array_map(function($field){ | |
| 145 | +        return array_map(function($field) { | |
| 146 | 146 | return array_merge([[ | 
| 147 | 147 | 'name' => $field['name'], | 
| 148 | 148 | 'args' => [] | 
| @@ -153,14 +153,14 @@ discard block | ||
| 153 | 153 | protected function foreignKeys() | 
| 154 | 154 |      { | 
| 155 | 155 |          $belongsTo = $this->option('belongs-to'); | 
| 156 | -        if(! $belongsTo) { | |
| 156 | +        if (!$belongsTo) { | |
| 157 | 157 | return []; | 
| 158 | 158 | } | 
| 159 | 159 |          $relations = $this->getArgumentParser('relations')->parse($belongsTo); | 
| 160 | -        return array_map(function($relation){ | |
| 160 | +        return array_map(function($relation) { | |
| 161 | 161 | $name = $relation['model'] ? $relation['model'] : $relation['name']; | 
| 162 | 162 | $index = strrpos($name, "\\"); | 
| 163 | -            if($index) { | |
| 163 | +            if ($index) { | |
| 164 | 164 | $name = substr($name, $index + 1); | 
| 165 | 165 | } | 
| 166 | 166 | return Str::snake(Str::singular($name)) . '_id'; | 
| @@ -181,12 +181,12 @@ discard block | ||
| 181 | 181 | |
| 182 | 182 | protected function factoryFields() | 
| 183 | 183 |      { | 
| 184 | -        return array_map(function($field){ | |
| 184 | +        return array_map(function($field) { | |
| 185 | 185 | return [ | 
| 186 | 186 | 'name' => $field['name'], | 
| 187 | 187 | 'type' => $field['factory'] | 
| 188 | 188 | ]; | 
| 189 | -        }, array_filter($this->fields, function($field){ | |
| 189 | +        }, array_filter($this->fields, function($field) { | |
| 190 | 190 | return isset($field['factory']) && $field['factory']; | 
| 191 | 191 | })); | 
| 192 | 192 | } | 
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php namespace Wn\Generators\Commands; | 
| 2 | 2 | |
| 3 | -use InvalidArgumentException; | |
| 4 | 3 | use Symfony\Component\Yaml\Yaml; | 
| 5 | 4 | use Illuminate\Support\Str; | 
| 6 | 5 | |
| @@ -75,7 +75,7 @@ | ||
| 75 | 75 | |
| 76 | 76 | protected function getResourceParams($modelName, $i) | 
| 77 | 77 |      { | 
| 78 | - $i['name'] = Str::snake($modelName); | |
| 78 | + $i['name'] = Str::snake($modelName); | |
| 79 | 79 | |
| 80 | 80 |          foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ | 
| 81 | 81 |              if(isset($i[$relation])){ | 
| @@ -24,10 +24,10 @@ discard block | ||
| 24 | 24 | $content = Yaml::parse($content); | 
| 25 | 25 | |
| 26 | 26 | $modelIndex = 0; | 
| 27 | -        foreach ($content as $model => $i){ | |
| 27 | +        foreach ($content as $model => $i) { | |
| 28 | 28 | $i = $this->getResourceParams($model, $i); | 
| 29 | - $migrationName = 'Create' . ucwords(Str::plural($i['name'])); | |
| 30 | -            $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex , 3, 0, STR_PAD_LEFT) . '_' . Str::snake($migrationName) . '_table'; | |
| 29 | + $migrationName = 'Create' . ucwords(Str::plural($i['name'])); | |
| 30 | +            $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex, 3, 0, STR_PAD_LEFT) . '_' . Str::snake($migrationName) . '_table'; | |
| 31 | 31 | |
| 32 | 32 | $options = [ | 
| 33 | 33 | 'name' => $i['name'], | 
| @@ -77,34 +77,34 @@ discard block | ||
| 77 | 77 |      { | 
| 78 | 78 | $i['name'] = Str::snake($modelName); | 
| 79 | 79 | |
| 80 | -        foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ | |
| 81 | -            if(isset($i[$relation])){ | |
| 80 | +        foreach (['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation) { | |
| 81 | +            if (isset($i[$relation])) { | |
| 82 | 82 | $i[$relation] = $this->convertArray($i[$relation], ' ', ','); | 
| 83 | 83 |              } else { | 
| 84 | 84 | $i[$relation] = false; | 
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | -        if($i['belongsToMany']){ | |
| 88 | +        if ($i['belongsToMany']) { | |
| 89 | 89 |              $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']); | 
| 90 | -            foreach ($relations as $relation){ | |
| 90 | +            foreach ($relations as $relation) { | |
| 91 | 91 | $table = ''; | 
| 92 | 92 | |
| 93 | -                if(! $relation['model']){ | |
| 93 | +                if (!$relation['model']) { | |
| 94 | 94 | $table = Str::snake($relation['name']); | 
| 95 | 95 |                  } else { | 
| 96 | 96 |                      $names = array_reverse(explode("\\", $relation['model'])); | 
| 97 | 97 | $table = Str::snake($names[0]); | 
| 98 | 98 | } | 
| 99 | 99 | |
| 100 | - $tables = [ Str::singular($table), $i['name'] ]; | |
| 100 | + $tables = [Str::singular($table), $i['name']]; | |
| 101 | 101 | sort($tables); | 
| 102 | 102 | $this->pivotTables[] = $tables; | 
| 103 | 103 | } | 
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 | $fields = []; | 
| 107 | -        foreach($i['fields'] as $name => $value) { | |
| 107 | +        foreach ($i['fields'] as $name => $value) { | |
| 108 | 108 | $value['name'] = $name; | 
| 109 | 109 | $fields[] = $this->serializeField($value); | 
| 110 | 110 | } | 
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 |          $string = "{$name};{$schema};{$rules};{$tags}"; | 
| 127 | 127 | |
| 128 | -        if(isset($field['factory']) && !empty($field['factory'])){ | |
| 128 | +        if (isset($field['factory']) && !empty($field['factory'])) { | |
| 129 | 129 | $string .= ';' . $field['factory']; | 
| 130 | 130 | } | 
| 131 | 131 | |
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | |
| 135 | 135 | protected function convertArray($list, $old, $new) | 
| 136 | 136 |      { | 
| 137 | -        return implode($new, array_filter(explode($old, $list), function($item){ | |
| 137 | +        return implode($new, array_filter(explode($old, $list), function($item) { | |
| 138 | 138 | return !empty($item); | 
| 139 | 139 | })); | 
| 140 | 140 | } | 
| @@ -67,7 +67,7 @@ | ||
| 67 | 67 | protected function getController() | 
| 68 | 68 |      { | 
| 69 | 69 |          $controller = $this->option('controller'); | 
| 70 | -        if(! $controller){ | |
| 70 | +        if (!$controller) { | |
| 71 | 71 |              $controller = ucwords(\Illuminate\Support\Str::plural(\Illuminate\Support\Str::camel($this->argument('resource')))) . 'Controller'; | 
| 72 | 72 | } | 
| 73 | 73 | return $controller; | 
| @@ -45,7 +45,7 @@ | ||
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 |      protected function getSeederName($resources) { | 
| 48 | -        $resources = array_map(function($resource){ | |
| 48 | +        $resources = array_map(function($resource) { | |
| 49 | 49 | return ucwords(\Illuminate\Support\Str::camel($resource)); | 
| 50 | 50 | }, $resources); | 
| 51 | 51 |          return implode('', $resources) . 'TableSeeder'; | 
| @@ -45,12 +45,12 @@ discard block | ||
| 45 | 45 | protected function getAsArrayFields($arg, $isOption = true) | 
| 46 | 46 |      { | 
| 47 | 47 | $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); | 
| 48 | -        if(is_string($arg)){ | |
| 48 | +        if (is_string($arg)) { | |
| 49 | 49 |          	$arg = explode(',', $arg); | 
| 50 | -        } else if(! is_array($arg)) { | |
| 50 | +        } else if (!is_array($arg)) { | |
| 51 | 51 | $arg = []; | 
| 52 | 52 | } | 
| 53 | -        return implode(', ', array_map(function($item){ | |
| 53 | +        return implode(', ', array_map(function($item) { | |
| 54 | 54 | return '"' . $item . '"'; | 
| 55 | 55 | }, $arg)); | 
| 56 | 56 | } | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 |              $this->getRelationsByType('belongsToMany', 'belongs-to-many', true) | 
| 70 | 70 | ); | 
| 71 | 71 | |
| 72 | -        if(empty($relations)){ | |
| 72 | +        if (empty($relations)) { | |
| 73 | 73 | return " // Relationships"; | 
| 74 | 74 | } | 
| 75 | 75 | |
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 |      { | 
| 81 | 81 | $relations = []; | 
| 82 | 82 | $option = $this->option($option); | 
| 83 | -        if($option){ | |
| 83 | +        if ($option) { | |
| 84 | 84 | |
| 85 | 85 |              $items = $this->getArgumentParser('relations')->parse($option); | 
| 86 | 86 | |
| @@ -88,9 +88,9 @@ discard block | ||
| 88 | 88 | $template = $this->getTemplate($template); | 
| 89 | 89 |              foreach ($items as $item) { | 
| 90 | 90 | $item['type'] = $type; | 
| 91 | -                if(! $item['model']){ | |
| 91 | +                if (!$item['model']) { | |
| 92 | 92 | $item['model'] = $this->getNamespace() . '\\' . ucwords(\Illuminate\Support\Str::singular($item['name'])); | 
| 93 | -                } else if(strpos($item['model'], '\\') === false ){ | |
| 93 | +                } else if (strpos($item['model'], '\\') === false) { | |
| 94 | 94 | $item['model'] = $this->getNamespace() . '\\' . $item['model']; | 
| 95 | 95 | } | 
| 96 | 96 | $relations[] = $template->with($item)->get(); | 
| @@ -102,11 +102,11 @@ discard block | ||
| 102 | 102 | protected function getRules() | 
| 103 | 103 |      { | 
| 104 | 104 |          $rules = $this->option('rules'); | 
| 105 | -        if(! $rules){ | |
| 105 | +        if (!$rules) { | |
| 106 | 106 | return " // Validation rules"; | 
| 107 | 107 | } | 
| 108 | 108 | $items = $rules; | 
| 109 | -        if(! $this->option('parsed')){ | |
| 109 | +        if (!$this->option('parsed')) { | |
| 110 | 110 |              $items = $this->getArgumentParser('rules')->parse($rules); | 
| 111 | 111 | } | 
| 112 | 112 | $rules = []; | 
| @@ -3,7 +3,7 @@ discard block | ||
| 3 | 3 | |
| 4 | 4 |  class ModelCommand extends BaseCommand { | 
| 5 | 5 | |
| 6 | - protected $signature = 'wn:model | |
| 6 | + protected $signature = 'wn:model | |
| 7 | 7 |          {name : Name of the model.} | 
| 8 | 8 |          {--fillable= : the fillable fields.} | 
| 9 | 9 |          {--guarded= : the guarded fields.} | 
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 |          {--force= : override the existing files} | 
| 21 | 21 | '; | 
| 22 | 22 | |
| 23 | - protected $description = 'Generates a model class for a RESTfull resource'; | |
| 23 | + protected $description = 'Generates a model class for a RESTfull resource'; | |
| 24 | 24 | |
| 25 | 25 | public function handle() | 
| 26 | 26 |      { | 
| @@ -46,9 +46,9 @@ discard block | ||
| 46 | 46 | |
| 47 | 47 | protected function getAsArrayFields($arg, $isOption = true) | 
| 48 | 48 |      { | 
| 49 | - $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); | |
| 49 | + $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); | |
| 50 | 50 |          if(is_string($arg)){ | 
| 51 | -        	$arg = explode(',', $arg); | |
| 51 | +            $arg = explode(',', $arg); | |
| 52 | 52 |          } else if(! is_array($arg)) { | 
| 53 | 53 | $arg = []; | 
| 54 | 54 | } | 
| @@ -59,7 +59,7 @@ discard block | ||
| 59 | 59 | |
| 60 | 60 | protected function getNamespace() | 
| 61 | 61 |      { | 
| 62 | -    	return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path')))); | |
| 62 | +        return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path')))); | |
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | protected function getRelations() | 
| @@ -44,6 +44,9 @@ discard block | ||
| 44 | 44 |          $this->save($content, "./App/Models/{$name}.php", "{$name} model"); | 
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | + /** | |
| 48 | + * @param string $arg | |
| 49 | + */ | |
| 47 | 50 | protected function getAsArrayFields($arg, $isOption = true) | 
| 48 | 51 |      { | 
| 49 | 52 | $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); | 
| @@ -78,6 +81,10 @@ discard block | ||
| 78 | 81 | return implode(PHP_EOL, $relations); | 
| 79 | 82 | } | 
| 80 | 83 | |
| 84 | + /** | |
| 85 | + * @param string $type | |
| 86 | + * @param string $option | |
| 87 | + */ | |
| 81 | 88 | protected function getRelationsByType($type, $option, $withTimestamps = false) | 
| 82 | 89 |      { | 
| 83 | 90 | $relations = []; | 
| @@ -5,33 +5,33 @@ | ||
| 5 | 5 | |
| 6 | 6 |  class ControllerCommand extends BaseCommand { | 
| 7 | 7 | |
| 8 | - protected $signature = 'wn:controller | |
| 8 | + protected $signature = 'wn:controller | |
| 9 | 9 |          {model : Name of the model (with namespace if not App)} | 
| 10 | 10 |  		{--no-routes= : without routes} | 
| 11 | 11 |          {--force= : override the existing files} | 
| 12 | 12 |          {--laravel : Use Laravel style route definitions} | 
| 13 | 13 | '; | 
| 14 | 14 | |
| 15 | - protected $description = 'Generates RESTful controller using the RESTActions trait'; | |
| 15 | + protected $description = 'Generates RESTful controller using the RESTActions trait'; | |
| 16 | 16 | |
| 17 | 17 | public function handle() | 
| 18 | 18 |      { | 
| 19 | -    	$model = $this->argument('model'); | |
| 20 | - $name = ''; | |
| 21 | -    	if(strrpos($model, "\\") === false){ | |
| 22 | - $name = $model; | |
| 23 | - $model = "App\\" . $model; | |
| 24 | -    	} else { | |
| 25 | -    		$name = explode("\\", $model); | |
| 26 | - $name = $name[count($name) - 1]; | |
| 27 | - } | |
| 19 | +        $model = $this->argument('model'); | |
| 20 | + $name = ''; | |
| 21 | +        if(strrpos($model, "\\") === false){ | |
| 22 | + $name = $model; | |
| 23 | + $model = "App\\" . $model; | |
| 24 | +        } else { | |
| 25 | +            $name = explode("\\", $model); | |
| 26 | + $name = $name[count($name) - 1]; | |
| 27 | + } | |
| 28 | 28 | $controller = ucwords(\Illuminate\Support\Str::plural($name)) . 'Controller'; | 
| 29 | 29 |          $content = $this->getTemplate('controller') | 
| 30 | - ->with([ | |
| 31 | - 'name' => $controller, | |
| 32 | - 'model' => $model | |
| 33 | - ]) | |
| 34 | - ->get(); | |
| 30 | + ->with([ | |
| 31 | + 'name' => $controller, | |
| 32 | + 'model' => $model | |
| 33 | + ]) | |
| 34 | + ->get(); | |
| 35 | 35 | |
| 36 | 36 |          $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); | 
| 37 | 37 |          if(! $this->option('no-routes')){ | 
| @@ -18,7 +18,7 @@ discard block | ||
| 18 | 18 |      { | 
| 19 | 19 |      	$model = $this->argument('model'); | 
| 20 | 20 | $name = ''; | 
| 21 | -    	if(strrpos($model, "\\") === false){ | |
| 21 | +    	if (strrpos($model, "\\") === false) { | |
| 22 | 22 | $name = $model; | 
| 23 | 23 | $model = "App\\" . $model; | 
| 24 | 24 |      	} else { | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | ->get(); | 
| 35 | 35 | |
| 36 | 36 |          $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); | 
| 37 | -        if(! $this->option('no-routes')){ | |
| 37 | +        if (!$this->option('no-routes')) { | |
| 38 | 38 | $options = [ | 
| 39 | 39 | 'resource' => \Illuminate\Support\Str::snake($name, '-'), | 
| 40 | 40 | '--controller' => $controller, | 
| @@ -34,10 +34,10 @@ discard block | ||
| 34 | 34 | ->get(); | 
| 35 | 35 | |
| 36 | 36 |          $file = $this->option('file'); | 
| 37 | -        if(! $file){ | |
| 37 | +        if (!$file) { | |
| 38 | 38 |              $file = date('Y_m_d_His_') . $snakeName . '_table'; | 
| 39 | 39 | $this->deleteOldMigration($snakeName); | 
| 40 | -        }else{ | |
| 40 | +        } else { | |
| 41 | 41 | $this->deleteOldMigration($file); | 
| 42 | 42 | } | 
| 43 | 43 | |
| @@ -46,10 +46,10 @@ discard block | ||
| 46 | 46 | |
| 47 | 47 | protected function deleteOldMigration($fileName) | 
| 48 | 48 |      { | 
| 49 | -        foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){ | |
| 50 | - if($fileInfo->isDot()) continue; | |
| 49 | +        foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo) { | |
| 50 | + if ($fileInfo->isDot()) continue; | |
| 51 | 51 | |
| 52 | -            if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){ | |
| 52 | +            if (strpos($fileInfo->getFilename(), $fileName) !== FALSE) { | |
| 53 | 53 | unlink($fileInfo->getPathname()); | 
| 54 | 54 | } | 
| 55 | 55 | } | 
| @@ -58,12 +58,12 @@ discard block | ||
| 58 | 58 | protected function getSchema() | 
| 59 | 59 |      { | 
| 60 | 60 |          $schema = $this->option('schema'); | 
| 61 | -        if(! $schema){ | |
| 61 | +        if (!$schema) { | |
| 62 | 62 | return $this->spaces(12) . "// Schema declaration"; | 
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | $items = $schema; | 
| 66 | -        if( ! $this->option('parsed')){ | |
| 66 | +        if (!$this->option('parsed')) { | |
| 67 | 67 |              $items = $this->getArgumentParser('schema')->parse($schema); | 
| 68 | 68 | } | 
| 69 | 69 | |
| @@ -97,7 +97,7 @@ discard block | ||
| 97 | 97 | $name = $parts[0]['name']; | 
| 98 | 98 |          $parts[1]['args'] = array_merge(["'{$name}'"], $parts[1]['args']); | 
| 99 | 99 | unset($parts[0]); | 
| 100 | -        $parts = array_map(function($part){ | |
| 100 | +        $parts = array_map(function($part) { | |
| 101 | 101 |              return '->' . $part['name'] . '(' . implode(', ', $part['args']) . ')'; | 
| 102 | 102 | }, $parts); | 
| 103 | 103 |          return "            \$table" . implode('', $parts) . ';'; | 
| @@ -106,12 +106,12 @@ discard block | ||
| 106 | 106 | protected function getConstraints() | 
| 107 | 107 |      { | 
| 108 | 108 |          $keys = $this->option('keys'); | 
| 109 | -        if(! $keys){ | |
| 109 | +        if (!$keys) { | |
| 110 | 110 | return $this->spaces(12) . "// Constraints declaration"; | 
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | 113 | $items = $keys; | 
| 114 | -        if(! $this->option('parsed')){ | |
| 114 | +        if (!$this->option('parsed')) { | |
| 115 | 115 |              $items = $this->getArgumentParser('foreign-keys')->parse($keys); | 
| 116 | 116 | } | 
| 117 | 117 | |
| @@ -125,10 +125,10 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 | protected function getConstraintDeclaration($key) | 
| 127 | 127 |      { | 
| 128 | -        if(! $key['column']){ | |
| 128 | +        if (!$key['column']) { | |
| 129 | 129 | $key['column'] = 'id'; | 
| 130 | 130 | } | 
| 131 | -        if(! $key['table']){ | |
| 131 | +        if (!$key['table']) { | |
| 132 | 132 | $key['table'] = \Illuminate\Support\Str::plural(substr($key['name'], 0, strlen($key['name']) - 3)); | 
| 133 | 133 | } | 
| 134 | 134 | |
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | ]) | 
| 141 | 141 | ->get(); | 
| 142 | 142 | |
| 143 | -        if($key['on_delete']){ | |
| 143 | +        if ($key['on_delete']) { | |
| 144 | 144 |              $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') | 
| 145 | 145 | ->with([ | 
| 146 | 146 | 'event' => 'Delete', | 
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | ->get(); | 
| 150 | 150 | } | 
| 151 | 151 | |
| 152 | -        if($key['on_update']){ | |
| 152 | +        if ($key['on_update']) { | |
| 153 | 153 |              $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') | 
| 154 | 154 | ->with([ | 
| 155 | 155 | 'event' => 'Update', |