Completed
Pull Request — master (#66)
by
unknown
02:30 queued 46s
created
src/Commands/RouteCommand.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class RouteCommand extends BaseCommand {
7 7
 
8
-	protected $signature = 'wn:route
8
+    protected $signature = 'wn:route
9 9
 		{resource : Name of the resource.}
10 10
         {--controller= : Name of the RESTful controller.}
11 11
 		{--controller-namespace= : Namespace of the RESTful controller if not default.}
@@ -13,22 +13,22 @@  discard block
 block discarded – undo
13 13
         {--laravel= : Use Laravel style route definitions}
14 14
     ';
15 15
 
16
-	protected $description = 'Generates RESTful routes.';
16
+    protected $description = 'Generates RESTful routes.';
17 17
 
18 18
     public function handle()
19 19
     {
20 20
         $resource = $this->argument('resource');
21 21
         $laravelRoutes = $this->option('laravel');
22
-		$templateFile = 'routes';
22
+        $templateFile = 'routes';
23 23
         $routesPath = $this->option('path') ?: 'routes/web.php';
24 24
         if ($laravelRoutes) {
25 25
             $templateFile = 'routes-laravel';
26 26
             $routesPath = $this->option('path') ?: 'routes/api.php';
27
-			if (!$this->fs->isFile($routesPath)) {
28
-				if (!$this->fs->isDirectory(\dirname($routesPath))) {
29
-					$this->fs->makeDirectory(\dirname($routesPath));
30
-				}
31
-				$this->fs->put($routesPath, "
27
+            if (!$this->fs->isFile($routesPath)) {
28
+                if (!$this->fs->isDirectory(\dirname($routesPath))) {
29
+                    $this->fs->makeDirectory(\dirname($routesPath));
30
+                }
31
+                $this->fs->put($routesPath, "
32 32
 	<?php
33 33
 
34 34
 	use Illuminate\Http\Request;
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	});
50 50
 
51 51
 			");
52
-			}
52
+            }
53
+        }
54
+        if ($this->option('controller-namespace')) {
55
+            $templateFile .= '-namespace';
53 56
         }
54
-		if ($this->option('controller-namespace')) {
55
-			$templateFile .= '-namespace';
56
-		}
57 57
 
58 58
         if (!$this->fs->isFile($routesPath)) {
59 59
             $routesPath = 'app/Http/routes.php';
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                 ->with([
65 65
                     'resource' => $resource,
66 66
                     'controller' => $this->getController(),
67
-					'namespace' => $this->option('controller-namespace'),
67
+                    'namespace' => $this->option('controller-namespace'),
68 68
                 ])
69 69
                 ->get();
70 70
         $this->save($content, $routesPath, "{$resource} routes", true);
Please login to merge, or discard this patch.
src/Commands/ControllerCommand.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 
6 6
 class ControllerCommand extends BaseCommand {
7 7
 
8
-	const DEFAULT_PATH = "app/Http/Controllers";
8
+    const DEFAULT_PATH = "app/Http/Controllers";
9 9
 
10
-	protected $signature = 'wn:controller
10
+    protected $signature = 'wn:controller
11 11
         {model : Name of the model (with namespace if not App)}
12 12
 		{--path='.ControllerCommand::DEFAULT_PATH.' : where to store the controllers file.}
13 13
 		{--no-routes= : without routes}
@@ -16,28 +16,28 @@  discard block
 block discarded – undo
16 16
         {--laravel : Use Laravel style route definitions}
17 17
     ';
18 18
 
19
-	protected $description = 'Generates RESTful controller using the RESTActions trait';
19
+    protected $description = 'Generates RESTful controller using the RESTActions trait';
20 20
 
21 21
     public function handle()
22 22
     {
23
-    	$model = $this->argument('model');
24
-    	$name = '';
25
-    	if(strrpos($model, "\\") === false){
26
-    		$name = $model;
27
-    		$model = "App\\" . $model;
28
-    	} else {
29
-    		$name = explode("\\", $model);
30
-    		$name = $name[count($name) - 1];
31
-    	}
23
+        $model = $this->argument('model');
24
+        $name = '';
25
+        if(strrpos($model, "\\") === false){
26
+            $name = $model;
27
+            $model = "App\\" . $model;
28
+        } else {
29
+            $name = explode("\\", $model);
30
+            $name = $name[count($name) - 1];
31
+        }
32 32
         $controller = ucwords(str_plural($name)) . 'Controller';
33 33
         $content = $this->getTemplate('controller')
34
-        	->with([
35
-        		'name' => $controller,
36
-        		'model' => $model,
37
-				'namespace' => $this->getNamespace(),
38
-				'use' => ($this->getNamespace() != $this->getDefaultNamespace()?'use '.$this->getDefaultNamespace().'\Controller;'.PHP_EOL.'use '.$this->getDefaultNamespace().'\RESTActions;'.PHP_EOL:'')
39
-        	])
40
-        	->get();
34
+            ->with([
35
+                'name' => $controller,
36
+                'model' => $model,
37
+                'namespace' => $this->getNamespace(),
38
+                'use' => ($this->getNamespace() != $this->getDefaultNamespace()?'use '.$this->getDefaultNamespace().'\Controller;'.PHP_EOL.'use '.$this->getDefaultNamespace().'\RESTActions;'.PHP_EOL:'')
39
+            ])
40
+            ->get();
41 41
 
42 42
         $this->save($content, "./{$this->option('path')}/{$controller}.php", "{$controller}");
43 43
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
         }
62 62
     }
63 63
 
64
-	protected function getDefaultNamespace() {
65
-		return $this->getNamespace(ControllerCommand::DEFAULT_PATH);
66
-	}
64
+    protected function getDefaultNamespace() {
65
+        return $this->getNamespace(ControllerCommand::DEFAULT_PATH);
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
src/Commands/MorphTableCommand.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 class MorphTableCommand extends BaseCommand {
5 5
 
6
-	protected $signature = 'wn:morph-table
6
+    protected $signature = 'wn:morph-table
7 7
         {model : Name of the persistant model or table}
8 8
         {morphable : Name of the morphable identifier}
9 9
         {--add= : specifies additional columns like timestamps, softDeletes, rememberToken and nullableTimestamps.}
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
         {--force= : override the existing files}
12 12
     ';
13 13
 
14
-	protected $description = 'Generates creation migration for a morphable pivot table';
14
+    protected $description = 'Generates creation migration for a morphable pivot table';
15 15
 
16 16
     protected $fields;
17 17
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     protected function keys()
49 49
     {
50 50
         // return implode(' ', $this->fields);
51
-		return snake_case(str_singular($this->argument('model')))."_id";
51
+        return snake_case(str_singular($this->argument('model')))."_id";
52 52
     }
53 53
 
54 54
 }
Please login to merge, or discard this patch.
src/Commands/ResourcesCommand.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -46,45 +46,45 @@  discard block
 block discarded – undo
46 46
         $morphTables = $this->uniqueArray($this->getTables($nodes, 'morphTables'));
47 47
 
48 48
         if (! $this->option('skip-check')) {
49
-        	$this->info('Checking Relationships...');
50
-        	$keys = array_keys($nodes);
51
-        	foreach ($nodes as $model => $i) {
52
-        		$this->checkRelations($i['belongsTo'], 'belongsTo', $i['filename'], $i['uniquename'], $keys);
53
-        		// $this->checkRelations($i['hasManyThrough'], 'hasManyThrough', $file, $model);
54
-        	}
55
-        	$this->checkPivotRelations($nodes, $pivotTables, 'pivot');
56
-        	$this->checkPivotRelations($nodes, $morphTables, 'morph');
49
+            $this->info('Checking Relationships...');
50
+            $keys = array_keys($nodes);
51
+            foreach ($nodes as $model => $i) {
52
+                $this->checkRelations($i['belongsTo'], 'belongsTo', $i['filename'], $i['uniquename'], $keys);
53
+                // $this->checkRelations($i['hasManyThrough'], 'hasManyThrough', $file, $model);
54
+            }
55
+            $this->checkPivotRelations($nodes, $pivotTables, 'pivot');
56
+            $this->checkPivotRelations($nodes, $morphTables, 'morph');
57 57
         }
58 58
 
59 59
         if ($this->checkedErrors > 0) {
60
-        	$this->line('');
61
-        	if ($this->option('check-only')) {
62
-        		$this->info('Checking only, we have found ' . $this->checkedErrors . ' errors.');
63
-        	}
64
-        	$this->printErrors();
60
+            $this->line('');
61
+            if ($this->option('check-only')) {
62
+                $this->info('Checking only, we have found ' . $this->checkedErrors . ' errors.');
63
+            }
64
+            $this->printErrors();
65 65
         }
66 66
 
67 67
         $proceed = (! $this->option('check-only') && $this->checkedErrors == 0) || $this->option('skip-check');
68 68
         if (! $this->option('check-only') && $this->checkedErrors > 0) {
69
-        	$this->line('');
70
-        	$proceed = $this->confirm("We have found " . $this->checkedErrors . " errors. Are you sure you want to continue?");
69
+            $this->line('');
70
+            $proceed = $this->confirm("We have found " . $this->checkedErrors . " errors. Are you sure you want to continue?");
71 71
         }
72 72
         if ($proceed) {
73
-        	$this->buildResources($nodes);
73
+            $this->buildResources($nodes);
74 74
 
75
-        	// if (!$this->option('no-migration')) {
76
-        	// 	$this->call('migrate'); // actually needed for pivot seeders !
77
-        	// }
75
+            // if (!$this->option('no-migration')) {
76
+            // 	$this->call('migrate'); // actually needed for pivot seeders !
77
+            // }
78 78
 
79
-        	$this->line('');
79
+            $this->line('');
80 80
             $this->buildTables('Pivot-Table', 'wn:pivot-table', 'model1', 'model2', $pivotTables);
81 81
 
82
-        	$this->line('');
82
+            $this->line('');
83 83
             $this->buildTables('Morph-Table', 'wn:morph-table', 'model', 'morphable', $morphTables);
84 84
 
85
-        	if (!$this->option('no-migration')) {
86
-        		$this->call('migrate');
87
-        	}
85
+            if (!$this->option('no-migration')) {
86
+                $this->call('migrate');
87
+            }
88 88
         }
89 89
     }
90 90
 
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
                 $deps = $this->getArgumentParser('relations')->parse($nodes[$key]['belongsTo']);
372 372
                 foreach($deps as $dependency) {
373 373
                     if(! $dependency['model']){
374
-	                    $dependency['model'] = $dependency['name'];
375
-	                } else if(strpos($dependency['model'], '\\') !== false ){
376
-	                    $dependency['model'] = substr($dependency['model'], strpos($dependency['model'], '\\')+1); // Cut offs first namespace part
377
-	                }
374
+                        $dependency['model'] = $dependency['name'];
375
+                    } else if(strpos($dependency['model'], '\\') !== false ){
376
+                        $dependency['model'] = substr($dependency['model'], strpos($dependency['model'], '\\')+1); // Cut offs first namespace part
377
+                    }
378 378
                     $dependency['model'] = studly_case(str_singular($dependency['model']));
379 379
                     if ($dependency['model'] != $key) {
380 380
                         $tmp = $this->getDependencies($nodes, $dependency['model'], $seen);
Please login to merge, or discard this patch.
src/Commands/ModelCommand.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
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
         {--dates= : date fields.}
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         {--force= : override the existing files}
25 25
     ';
26 26
 
27
-	protected $description = 'Generates a model class for a RESTfull resource';
27
+    protected $description = 'Generates a model class for a RESTfull resource';
28 28
 
29 29
     public function handle()
30 30
     {
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
     protected function getAsArrayFields($arg, $isOption = true)
51 51
     {
52
-    	$arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
52
+        $arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
53 53
         if(is_string($arg)){
54
-        	$arg = explode(',', $arg);
54
+            $arg = explode(',', $arg);
55 55
         } else if(! is_array($arg)) {
56 56
             $arg = [];
57 57
         }
@@ -93,32 +93,32 @@  discard block
 block discarded – undo
93 93
             $template = $this->getTemplate($template);
94 94
             foreach ($items as $item) {
95 95
                 $item['type'] = $type;
96
-				if ($parser == 'relations') {
97
-					$item['model'] = $this->prependNamespace($item['model'] ?: $item['name']);
98
-				} else if ($parser != 'relations') {
99
-					switch($type) {
100
-						case "hasManyThrough":
101
-							if(! $item['through'] && $item['model']){
102
-								$item['through'] = $this->prependNamespace($item['model']);
103
-								$item['model'] = $this->prependNamespace($item['name']);
104
-							} else {
105
-								$item['through'] = $this->prependNamespace($item['through']);
106
-								$item['model'] = $this->prependNamespace($item['model']);
107
-							}
108
-							break;
109
-						case "morphMany":
110
-						case "morphToMany":
111
-						case "morphedByMany":
112
-							if(! $item['through']){
113
-								$item['through'] = $item['model'];
114
-								$item['model'] = $this->prependNamespace($item['name']);
115
-							} else {
116
-								$item['model'] = $this->prependNamespace($item['model']);
117
-							}
118
-							break;
119
-
120
-					}
121
-				}
96
+                if ($parser == 'relations') {
97
+                    $item['model'] = $this->prependNamespace($item['model'] ?: $item['name']);
98
+                } else if ($parser != 'relations') {
99
+                    switch($type) {
100
+                        case "hasManyThrough":
101
+                            if(! $item['through'] && $item['model']){
102
+                                $item['through'] = $this->prependNamespace($item['model']);
103
+                                $item['model'] = $this->prependNamespace($item['name']);
104
+                            } else {
105
+                                $item['through'] = $this->prependNamespace($item['through']);
106
+                                $item['model'] = $this->prependNamespace($item['model']);
107
+                            }
108
+                            break;
109
+                        case "morphMany":
110
+                        case "morphToMany":
111
+                        case "morphedByMany":
112
+                            if(! $item['through']){
113
+                                $item['through'] = $item['model'];
114
+                                $item['model'] = $this->prependNamespace($item['name']);
115
+                            } else {
116
+                                $item['model'] = $this->prependNamespace($item['model']);
117
+                            }
118
+                            break;
119
+
120
+                    }
121
+                }
122 122
                 $relations[] = $template->with($item)->get();
123 123
             }
124 124
         }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     protected function getRules()
129 129
     {
130 130
         $items = $this->parseValue($this->option('rules'), 'rules');
131
-		if ($items === false) {
132
-			return $this->spaces(8) . "// Validation rules";
133
-		}
131
+        if ($items === false) {
132
+            return $this->spaces(8) . "// Validation rules";
133
+        }
134 134
 
135 135
         $template = $this->getTemplate('model/rule');
136 136
         $rules = [];
Please login to merge, or discard this patch.
src/Commands/BaseCommand.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 class BaseCommand extends Command {
11 11
 
12 12
     protected $fs;
13
-	protected $templates;
13
+    protected $templates;
14 14
 
15
-	public function __construct(Filesystem $fs)
16
-	{
15
+    public function __construct(Filesystem $fs)
16
+    {
17 17
         parent::__construct();
18 18
 
19 19
         $this->fs = $fs;
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 
57 57
     protected function getNamespace(string $path = null): string
58 58
     {
59
-		if (! $path) {
60
-			$path = $this->option('path');
61
-		}
59
+        if (! $path) {
60
+            $path = $this->option('path');
61
+        }
62 62
 
63
-    	return implode('\\', array_map('studly_case', array_filter(array_map('trim', explode('/', $path)), function($value) {
63
+        return implode('\\', array_map('studly_case', array_filter(array_map('trim', explode('/', $path)), function($value) {
64 64
             return !empty($value);
65 65
         })));
66 66
     }
Please login to merge, or discard this patch.