Completed
Push — master ( 63d8d6...28be9d )
by Raphael
11:25
created
src/Scaffolder/Commands/BuildCommand.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,60 +13,60 @@
 block discarded – undo
13 13
 
14 14
 class BuildCommand extends Command
15 15
 {
16
-	protected $signature = 'scaffolder:build {app=webapp}';
16
+    protected $signature = 'scaffolder:build {app=webapp}';
17 17
 
18
-	protected $description = 'Build the generated code to public folder';
18
+    protected $description = 'Build the generated code to public folder';
19 19
 
20
-	/**
21
-	 * Execute the Command.
22
-	 */
23
-	public function handle()
24
-	{
20
+    /**
21
+     * Execute the Command.
22
+     */
23
+    public function handle()
24
+    {
25 25
 
26 26
 
27
-		switch ($this->argument('app')) {
28
-			case 'webapp':
27
+        switch ($this->argument('app')) {
28
+            case 'webapp':
29 29
 				
30
-				$this->cleanPublicFolder();
30
+                $this->cleanPublicFolder();
31 31
 
32
-				$gulpCommand = sprintf('gulp build --cwd "%s/codificar/scaffolder-theme-material/"', base_path('vendor'));
32
+                $gulpCommand = sprintf('gulp build --cwd "%s/codificar/scaffolder-theme-material/"', base_path('vendor'));
33 33
 
34
-				//$this->info('- gulpCommand: '. $gulpCommand);	
34
+                //$this->info('- gulpCommand: '. $gulpCommand);	
35 35
 
36
-				$handle = popen($gulpCommand, 'r');
36
+                $handle = popen($gulpCommand, 'r');
37 37
 
38
-				while(!feof($handle)) 
39
-				{ 
40
-					// send the current file part to the browser 
41
-					$this->info(fread($handle, 1024)); 
42
-				} 
38
+                while(!feof($handle)) 
39
+                { 
40
+                    // send the current file part to the browser 
41
+                    $this->info(fread($handle, 1024)); 
42
+                } 
43 43
 
44
-				fclose($handle); 
44
+                fclose($handle); 
45 45
 				
46
-				// php artisan serve
47
-				$this->call('serve');
46
+                // php artisan serve
47
+                $this->call('serve');
48 48
 
49
-				break;
49
+                break;
50 50
 
51
-			default:
52
-				$this->info('Invalid arguments');
53
-				break;
54
-		}
51
+            default:
52
+                $this->info('Invalid arguments');
53
+                break;
54
+        }
55 55
 		
56
-	}
56
+    }
57 57
 
58
-	private function cleanPublicFolder(){
59
-		$this->info('Cleaning public directory');
58
+    private function cleanPublicFolder(){
59
+        $this->info('Cleaning public directory');
60 60
 
61
-		File::deleteDirectory(sprintf("%s/app", base_path('public')));
62
-		File::deleteDirectory(sprintf("%s/assets", base_path('public')));
63
-		File::deleteDirectory(sprintf("%s/fonts", base_path('public')));
64
-		File::deleteDirectory(sprintf("%s/maps", base_path('public')));
65
-		File::deleteDirectory(sprintf("%s/scripts", base_path('public')));
66
-		File::deleteDirectory(sprintf("%s/styles", base_path('public')));
61
+        File::deleteDirectory(sprintf("%s/app", base_path('public')));
62
+        File::deleteDirectory(sprintf("%s/assets", base_path('public')));
63
+        File::deleteDirectory(sprintf("%s/fonts", base_path('public')));
64
+        File::deleteDirectory(sprintf("%s/maps", base_path('public')));
65
+        File::deleteDirectory(sprintf("%s/scripts", base_path('public')));
66
+        File::deleteDirectory(sprintf("%s/styles", base_path('public')));
67 67
 
68
-		File::delete(sprintf("%s/index.html", base_path('public')));
69
-	}
68
+        File::delete(sprintf("%s/index.html", base_path('public')));
69
+    }
70 70
 
71 71
 
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Illuminate\Console\Command;
6 6
 use Illuminate\Support\Facades\File;
7 7
 
8
-use stdClass ;
8
+use stdClass;
9 9
 
10 10
 // Support classes
11 11
 use Scaffolder\Support\Directory;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 				$handle = popen($gulpCommand, 'r');
37 37
 
38
-				while(!feof($handle)) 
38
+				while (!feof($handle)) 
39 39
 				{ 
40 40
 					// send the current file part to the browser 
41 41
 					$this->info(fread($handle, 1024)); 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		
56 56
 	}
57 57
 
58
-	private function cleanPublicFolder(){
58
+	private function cleanPublicFolder() {
59 59
 		$this->info('Cleaning public directory');
60 60
 
61 61
 		File::deleteDirectory(sprintf("%s/app", base_path('public')));
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Blade/PageLayoutCompiler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
46 46
     {
47
-        $path = PathParser::parse($scaffolderConfig->generator->paths->views) . 'layouts/page.blade.php';
47
+        $path = PathParser::parse($scaffolderConfig->generator->paths->views).'layouts/page.blade.php';
48 48
 
49 49
         File::put($path, $compiled);
50 50
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 <a href='/%s' class='waves-effect'>
99 99
                     %ss
100 100
                 </a>
101
-            </li>", $scaffolderConfig->generator->routing->prefix . '/' . strtolower($link), $link);
101
+            </li>", $scaffolderConfig->generator->routing->prefix.'/'.strtolower($link), $link);
102 102
         }
103 103
 
104 104
         $this->stub = str_replace('{{links}}', $navLinks, $this->stub);
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Blade/CreateViewCompiler.php 3 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -11,112 +11,112 @@
 block discarded – undo
11 11
 
12 12
 class CreateViewCompiler extends AbstractViewCompiler
13 13
 {
14
-	use InputTypeResolverTrait;
14
+    use InputTypeResolverTrait;
15 15
 
16
-	/**
17
-	 * Compiles the create view.
18
-	 *
19
-	 * @param      $stub
20
-	 * @param      $modelName
21
-	 * @param      $modelData
22
-	 * @param      $scaffolderConfig
23
-	 * @param      $hash
24
-	 * @param null $extra
25
-	 *
26
-	 * @return string
27
-	 */
28
-	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
-	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31
-		{
32
-			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
35
-		{
36
-			$this->stub = $stub;
16
+    /**
17
+     * Compiles the create view.
18
+     *
19
+     * @param      $stub
20
+     * @param      $modelName
21
+     * @param      $modelData
22
+     * @param      $scaffolderConfig
23
+     * @param      $hash
24
+     * @param null $extra
25
+     *
26
+     * @return string
27
+     */
28
+    public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
+    {
30
+        if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31
+        {
32
+            return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
+        }
34
+        else
35
+        {
36
+            $this->stub = $stub;
37 37
 
38
-			return $this->replaceClassName($modelName)
39
-				->replaceBreadcrumb($modelName)
40
-				->addFields($modelData)
41
-				->replaceRoutePrefix($scaffolderConfig->generator->routing->prefix)
42
-				->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
43
-		}
44
-	}
38
+            return $this->replaceClassName($modelName)
39
+                ->replaceBreadcrumb($modelName)
40
+                ->addFields($modelData)
41
+                ->replaceRoutePrefix($scaffolderConfig->generator->routing->prefix)
42
+                ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
43
+        }
44
+    }
45 45
 
46
-	/**
47
-	 * Store the compiled stub.
48
-	 *
49
-	 * @param               $modelName
50
-	 * @param               $scaffolderConfig
51
-	 * @param               $compiled
52
-	 * @param FileToCompile $fileToCompile
53
-	 *
54
-	 * @return string
55
-	 */
56
-	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57
-	{
58
-		$folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
46
+    /**
47
+     * Store the compiled stub.
48
+     *
49
+     * @param               $modelName
50
+     * @param               $scaffolderConfig
51
+     * @param               $compiled
52
+     * @param FileToCompile $fileToCompile
53
+     *
54
+     * @return string
55
+     */
56
+    protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57
+    {
58
+        $folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
59 59
 		
60
-		// create folder directory
61
-		Directory::createIfNotExists($folder, 0755, true);
60
+        // create folder directory
61
+        Directory::createIfNotExists($folder, 0755, true);
62 62
 
63
-		$path = $folder  . '/create.blade.php';
63
+        $path = $folder  . '/create.blade.php';
64 64
 
65
-		// Store in cache
66
-		if ($fileToCompile->cached)
67
-		{
68
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
-		}
70
-		else
71
-		{
72
-			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
74
-		}
65
+        // Store in cache
66
+        if ($fileToCompile->cached)
67
+        {
68
+            File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
+        }
70
+        else
71
+        {
72
+            File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
+            File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
74
+        }
75 75
 
76
-		return $path;
77
-	}
76
+        return $path;
77
+    }
78 78
 
79
-	/**
80
-	 * Add fields to the create view.
81
-	 *
82
-	 * @param $modelData
83
-	 *
84
-	 * @return $this
85
-	 */
86
-	private function addFields($modelData)
87
-	{
88
-		$fields = '';
89
-		$firstIteration = true;
79
+    /**
80
+     * Add fields to the create view.
81
+     *
82
+     * @param $modelData
83
+     *
84
+     * @return $this
85
+     */
86
+    private function addFields($modelData)
87
+    {
88
+        $fields = '';
89
+        $firstIteration = true;
90 90
 
91
-		foreach ($modelData->fields as $field)
92
-		{
93
-			if ($firstIteration)
94
-			{
95
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
-				$firstIteration = false;
97
-			}
98
-			else
99
-			{
100
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
-			}
102
-		}
91
+        foreach ($modelData->fields as $field)
92
+        {
93
+            if ($firstIteration)
94
+            {
95
+                $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
+                $firstIteration = false;
97
+            }
98
+            else
99
+            {
100
+                $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
+            }
102
+        }
103 103
 
104
-		$this->stub = str_replace('{{fields}}', $fields, $this->stub);
104
+        $this->stub = str_replace('{{fields}}', $fields, $this->stub);
105 105
 
106
-		return $this;
107
-	}
106
+        return $this;
107
+    }
108 108
 
109
-	/**
110
-	 * Replace the prefix.
111
-	 *
112
-	 * @param $prefix
113
-	 *
114
-	 * @return $this
115
-	 */
116
-	private function replaceRoutePrefix($prefix)
117
-	{
118
-		$this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
109
+    /**
110
+     * Replace the prefix.
111
+     *
112
+     * @param $prefix
113
+     *
114
+     * @return $this
115
+     */
116
+    private function replaceRoutePrefix($prefix)
117
+    {
118
+        $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
119 119
 
120
-		return $this;
121
-	}
120
+        return $this;
121
+    }
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29 29
 	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
30
+		if (File::exists(base_path('scaffolder-config/cache/view_create_'.$hash.self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33 33
 		}
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57 57
 	{
58
-		$folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
58
+		$folder = PathParser::parse($scaffolderConfig->generator->paths->views).strtolower($modelName);
59 59
 		
60 60
 		// create folder directory
61 61
 		Directory::createIfNotExists($folder, 0755, true);
62 62
 
63
-		$path = $folder  . '/create.blade.php';
63
+		$path = $folder.'/create.blade.php';
64 64
 
65 65
 		// Store in cache
66 66
 		if ($fileToCompile->cached)
67 67
 		{
68
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
68
+			File::copy(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $path);
69 69
 		}
70 70
 		else
71 71
 		{
72
-			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
72
+			File::put(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $compiled);
73
+			File::copy(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $path);
74 74
 		}
75 75
 
76 76
 		return $path;
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 		{
93 93
 			if ($firstIteration)
94 94
 			{
95
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
95
+				$fields .= sprintf(self::getInputFor($field).PHP_EOL, $field->name);
96 96
 				$firstIteration = false;
97 97
 			}
98 98
 			else
99 99
 			{
100
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
100
+				$fields .= sprintf("\t".self::getInputFor($field).PHP_EOL, $field->name);
101 101
 			}
102 102
 		}
103 103
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
33
+		} else
35 34
 		{
36 35
 			$this->stub = $stub;
37 36
 
@@ -66,8 +65,7 @@  discard block
 block discarded – undo
66 65
 		if ($fileToCompile->cached)
67 66
 		{
68 67
 			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
-		}
70
-		else
68
+		} else
71 69
 		{
72 70
 			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73 71
 			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
 			{
95 93
 				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96 94
 				$firstIteration = false;
97
-			}
98
-			else
95
+			} else
99 96
 			{
100 97
 				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101 98
 			}
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Blade/EditViewCompiler.php 3 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -11,136 +11,136 @@
 block discarded – undo
11 11
 
12 12
 class EditViewCompiler extends AbstractViewCompiler
13 13
 {
14
-	use InputTypeResolverTrait;
15
-
16
-	/**
17
-	 * Compiles the edit view.
18
-	 *
19
-	 * @param      $stub
20
-	 * @param      $modelName
21
-	 * @param      $modelData
22
-	 * @param      $scaffolderConfig
23
-	 * @param      $hash
24
-	 * @param null $extra
25
-	 *
26
-	 * @return string
27
-	 */
28
-	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
-	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31
-		{
32
-			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
35
-		{
36
-			$this->stub = $stub;
37
-
38
-			return $this->replaceClassName($modelName)
39
-				->replaceBreadcrumb($modelName)
40
-				->addFields($modelData)
41
-				->replacePrimaryKey($modelData)
42
-				->replaceRoutePrefix($scaffolderConfig->generator->routing->prefix)
43
-				->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
44
-		}
45
-	}
46
-
47
-	/**
48
-	 * Store the compiled stub.
49
-	 *
50
-	 * @param               $modelName
51
-	 * @param               $scaffolderConfig
52
-	 * @param               $compiled
53
-	 * @param FileToCompile $fileToCompile
54
-	 *
55
-	 * @return string
56
-	 */
57
-	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58
-	{
59
-		$folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
14
+    use InputTypeResolverTrait;
15
+
16
+    /**
17
+     * Compiles the edit view.
18
+     *
19
+     * @param      $stub
20
+     * @param      $modelName
21
+     * @param      $modelData
22
+     * @param      $scaffolderConfig
23
+     * @param      $hash
24
+     * @param null $extra
25
+     *
26
+     * @return string
27
+     */
28
+    public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
+    {
30
+        if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31
+        {
32
+            return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
+        }
34
+        else
35
+        {
36
+            $this->stub = $stub;
37
+
38
+            return $this->replaceClassName($modelName)
39
+                ->replaceBreadcrumb($modelName)
40
+                ->addFields($modelData)
41
+                ->replacePrimaryKey($modelData)
42
+                ->replaceRoutePrefix($scaffolderConfig->generator->routing->prefix)
43
+                ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
44
+        }
45
+    }
46
+
47
+    /**
48
+     * Store the compiled stub.
49
+     *
50
+     * @param               $modelName
51
+     * @param               $scaffolderConfig
52
+     * @param               $compiled
53
+     * @param FileToCompile $fileToCompile
54
+     *
55
+     * @return string
56
+     */
57
+    protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58
+    {
59
+        $folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
60 60
 		
61
-		// create folder directory
62
-		Directory::createIfNotExists($folder, 0755, true);
63
-
64
-		$path   = $folder . '/edit.blade.php';
65
-
66
-		// Store in cache
67
-		if ($fileToCompile->cached)
68
-		{
69
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
-		}
71
-		else
72
-		{
73
-			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
75
-		}
76
-
77
-		return $path;
78
-	}
79
-
80
-	/**
81
-	 * Add fields to the edit view.
82
-	 *
83
-	 * @param $modelData
84
-	 *
85
-	 * @return $this
86
-	 */
87
-	private function addFields($modelData)
88
-	{
89
-		$fields = '';
90
-		$firstIteration = true;
91
-
92
-		foreach ($modelData->fields as $field)
93
-		{
94
-			if ($firstIteration)
95
-			{
96
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97
-				$firstIteration = false;
98
-			}
99
-			else
100
-			{
101
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102
-			}
103
-		}
104
-
105
-		$this->stub = str_replace('{{fields}}', $fields, $this->stub);
106
-
107
-		return $this;
108
-	}
109
-
110
-	/**
111
-	 * Replace the prefix.
112
-	 *
113
-	 * @param $prefix
114
-	 *
115
-	 * @return $this
116
-	 */
117
-	private function replaceRoutePrefix($prefix)
118
-	{
119
-		$this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
120
-
121
-		return $this;
122
-	}
123
-
124
-	/**
125
-	 * Replace the primary key.
126
-	 *
127
-	 * @param $modelData
128
-	 */
129
-	private function replacePrimaryKey($modelData)
130
-	{
131
-		$primaryKey = 'id';
132
-
133
-		foreach ($modelData->fields as $field)
134
-		{
135
-			if ($field->index == 'primary')
136
-			{
137
-				$primaryKey = $field->name;
138
-				break;
139
-			}
140
-		}
141
-
142
-		$this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub);
143
-
144
-		return $this;
145
-	}
61
+        // create folder directory
62
+        Directory::createIfNotExists($folder, 0755, true);
63
+
64
+        $path   = $folder . '/edit.blade.php';
65
+
66
+        // Store in cache
67
+        if ($fileToCompile->cached)
68
+        {
69
+            File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
+        }
71
+        else
72
+        {
73
+            File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
+            File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
75
+        }
76
+
77
+        return $path;
78
+    }
79
+
80
+    /**
81
+     * Add fields to the edit view.
82
+     *
83
+     * @param $modelData
84
+     *
85
+     * @return $this
86
+     */
87
+    private function addFields($modelData)
88
+    {
89
+        $fields = '';
90
+        $firstIteration = true;
91
+
92
+        foreach ($modelData->fields as $field)
93
+        {
94
+            if ($firstIteration)
95
+            {
96
+                $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97
+                $firstIteration = false;
98
+            }
99
+            else
100
+            {
101
+                $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102
+            }
103
+        }
104
+
105
+        $this->stub = str_replace('{{fields}}', $fields, $this->stub);
106
+
107
+        return $this;
108
+    }
109
+
110
+    /**
111
+     * Replace the prefix.
112
+     *
113
+     * @param $prefix
114
+     *
115
+     * @return $this
116
+     */
117
+    private function replaceRoutePrefix($prefix)
118
+    {
119
+        $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
120
+
121
+        return $this;
122
+    }
123
+
124
+    /**
125
+     * Replace the primary key.
126
+     *
127
+     * @param $modelData
128
+     */
129
+    private function replacePrimaryKey($modelData)
130
+    {
131
+        $primaryKey = 'id';
132
+
133
+        foreach ($modelData->fields as $field)
134
+        {
135
+            if ($field->index == 'primary')
136
+            {
137
+                $primaryKey = $field->name;
138
+                break;
139
+            }
140
+        }
141
+
142
+        $this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub);
143
+
144
+        return $this;
145
+    }
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29 29
 	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
30
+		if (File::exists(base_path('scaffolder-config/cache/view_edit_'.$hash.self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33 33
 		}
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58 58
 	{
59
-		$folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
59
+		$folder = PathParser::parse($scaffolderConfig->generator->paths->views).strtolower($modelName);
60 60
 		
61 61
 		// create folder directory
62 62
 		Directory::createIfNotExists($folder, 0755, true);
63 63
 
64
-		$path   = $folder . '/edit.blade.php';
64
+		$path = $folder.'/edit.blade.php';
65 65
 
66 66
 		// Store in cache
67 67
 		if ($fileToCompile->cached)
68 68
 		{
69
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
+			File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path);
70 70
 		}
71 71
 		else
72 72
 		{
73
-			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
73
+			File::put(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $compiled);
74
+			File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path);
75 75
 		}
76 76
 
77 77
 		return $path;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 		{
94 94
 			if ($firstIteration)
95 95
 			{
96
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
+				$fields .= sprintf(self::getInputFor($field).PHP_EOL, $field->name);
97 97
 				$firstIteration = false;
98 98
 			}
99 99
 			else
100 100
 			{
101
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
+				$fields .= sprintf("\t".self::getInputFor($field).PHP_EOL, $field->name);
102 102
 			}
103 103
 		}
104 104
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
33
+		} else
35 34
 		{
36 35
 			$this->stub = $stub;
37 36
 
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
 		if ($fileToCompile->cached)
68 67
 		{
69 68
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
-		}
71
-		else
69
+		} else
72 70
 		{
73 71
 			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74 72
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
 			{
96 94
 				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97 95
 				$firstIteration = false;
98
-			}
99
-			else
96
+			} else
100 97
 			{
101 98
 				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102 99
 			}
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Blade/IndexViewCompiler.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
26 26
     {
27
-        if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT)))
27
+        if (File::exists(base_path('scaffolder-config/cache/view_index_'.$hash.self::CACHE_EXT)))
28 28
         {
29 29
             return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
30 30
         }
@@ -53,22 +53,22 @@  discard block
 block discarded – undo
53 53
      */
54 54
     protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
55 55
     {
56
-        $folder = PathParser::parse($scaffolderConfig->generator->paths->views) . strtolower($modelName) ;
56
+        $folder = PathParser::parse($scaffolderConfig->generator->paths->views).strtolower($modelName);
57 57
         
58 58
         // create folder directory
59 59
         Directory::createIfNotExists($folder, 0755, true);
60 60
 
61
-        $path = $folder  . '/index.blade.php';
61
+        $path = $folder.'/index.blade.php';
62 62
 
63 63
         // Store in cache
64 64
         if ($fileToCompile->cached)
65 65
         {
66
-            File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
66
+            File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path);
67 67
         }
68 68
         else
69 69
         {
70
-            File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
71
-            File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
+            File::put(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $compiled);
71
+            File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path);
72 72
         }
73 73
 
74 74
         return $path;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
             {
94 94
                 if ($firstIteration)
95 95
                 {
96
-                    $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
96
+                    $fields .= sprintf("{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name);
97 97
                     $firstIteration = false;
98 98
                 }
99 99
                 else
100 100
                 {
101
-                    $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
101
+                    $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name);
102 102
                 }
103 103
             }
104 104
         }
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
             {
128 128
                 if ($firstIteration)
129 129
                 {
130
-                    $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name));
130
+                    $fields .= sprintf("<th>%s</th>".PHP_EOL, ucfirst($field->name));
131 131
                     $firstIteration = false;
132 132
 
133 133
                 }
134 134
                 else
135 135
                 {
136
-                    $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name));
136
+                    $fields .= sprintf("\t\t\t<th>%s</th>".PHP_EOL, ucfirst($field->name));
137 137
                 }
138 138
             }
139 139
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
         if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT)))
27 27
         {
28 28
             return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
29
-        }
30
-        else
29
+        } else
31 30
         {
32 31
             $this->stub = $stub;
33 32
 
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
         if ($fileToCompile->cached)
59 58
         {
60 59
             File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
61
-        }
62
-        else
60
+        } else
63 61
         {
64 62
             File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
65 63
             File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -89,8 +87,7 @@  discard block
 block discarded – undo
89 87
                 {
90 88
                     $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
91 89
                     $firstIteration = false;
92
-                }
93
-                else
90
+                } else
94 91
                 {
95 92
                     $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
96 93
                 }
@@ -124,8 +121,7 @@  discard block
 block discarded – undo
124 121
                     $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name));
125 122
                     $firstIteration = false;
126 123
 
127
-                }
128
-                else
124
+                } else
129 125
                 {
130 126
                     $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name));
131 127
                 }
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/View/PageLayoutCompiler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
46 46
     {
47
-        $path = PathParser::parse($scaffolderConfig->paths->views) . 'layouts/page.blade.php';
47
+        $path = PathParser::parse($scaffolderConfig->paths->views).'layouts/page.blade.php';
48 48
 
49 49
         File::put($path, $compiled);
50 50
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 <a href='/%s' class='waves-effect'>
99 99
                     %ss
100 100
                 </a>
101
-            </li>", $scaffolderConfig->routing->prefix . '/' . strtolower($link), $link);
101
+            </li>", $scaffolderConfig->routing->prefix.'/'.strtolower($link), $link);
102 102
         }
103 103
 
104 104
         $this->stub = str_replace('{{links}}', $navLinks, $this->stub);
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/View/CreateViewCompiler.php 3 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -11,112 +11,112 @@
 block discarded – undo
11 11
 
12 12
 class CreateViewCompiler extends AbstractViewCompiler
13 13
 {
14
-	use InputTypeResolverTrait;
14
+    use InputTypeResolverTrait;
15 15
 
16
-	/**
17
-	 * Compiles the create view.
18
-	 *
19
-	 * @param      $stub
20
-	 * @param      $modelName
21
-	 * @param      $modelData
22
-	 * @param      $scaffolderConfig
23
-	 * @param      $hash
24
-	 * @param null $extra
25
-	 *
26
-	 * @return string
27
-	 */
28
-	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
-	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31
-		{
32
-			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
35
-		{
36
-			$this->stub = $stub;
16
+    /**
17
+     * Compiles the create view.
18
+     *
19
+     * @param      $stub
20
+     * @param      $modelName
21
+     * @param      $modelData
22
+     * @param      $scaffolderConfig
23
+     * @param      $hash
24
+     * @param null $extra
25
+     *
26
+     * @return string
27
+     */
28
+    public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
+    {
30
+        if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31
+        {
32
+            return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
+        }
34
+        else
35
+        {
36
+            $this->stub = $stub;
37 37
 
38
-			return $this->replaceClassName($modelName)
39
-				->replaceBreadcrumb($modelName)
40
-				->addFields($modelData)
41
-				->replaceRoutePrefix($scaffolderConfig->routing->prefix)
42
-				->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
43
-		}
44
-	}
38
+            return $this->replaceClassName($modelName)
39
+                ->replaceBreadcrumb($modelName)
40
+                ->addFields($modelData)
41
+                ->replaceRoutePrefix($scaffolderConfig->routing->prefix)
42
+                ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
43
+        }
44
+    }
45 45
 
46
-	/**
47
-	 * Store the compiled stub.
48
-	 *
49
-	 * @param               $modelName
50
-	 * @param               $scaffolderConfig
51
-	 * @param               $compiled
52
-	 * @param FileToCompile $fileToCompile
53
-	 *
54
-	 * @return string
55
-	 */
56
-	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57
-	{
58
-		$folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
46
+    /**
47
+     * Store the compiled stub.
48
+     *
49
+     * @param               $modelName
50
+     * @param               $scaffolderConfig
51
+     * @param               $compiled
52
+     * @param FileToCompile $fileToCompile
53
+     *
54
+     * @return string
55
+     */
56
+    protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57
+    {
58
+        $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
59 59
 		
60
-		// create folder directory
61
-		Directory::createIfNotExists($folder, 0755, true);
60
+        // create folder directory
61
+        Directory::createIfNotExists($folder, 0755, true);
62 62
 
63
-		$path = $folder  . '/create.blade.php';
63
+        $path = $folder  . '/create.blade.php';
64 64
 
65
-		// Store in cache
66
-		if ($fileToCompile->cached)
67
-		{
68
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
-		}
70
-		else
71
-		{
72
-			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
74
-		}
65
+        // Store in cache
66
+        if ($fileToCompile->cached)
67
+        {
68
+            File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
+        }
70
+        else
71
+        {
72
+            File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
+            File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
74
+        }
75 75
 
76
-		return $path;
77
-	}
76
+        return $path;
77
+    }
78 78
 
79
-	/**
80
-	 * Add fields to the create view.
81
-	 *
82
-	 * @param $modelData
83
-	 *
84
-	 * @return $this
85
-	 */
86
-	private function addFields($modelData)
87
-	{
88
-		$fields = '';
89
-		$firstIteration = true;
79
+    /**
80
+     * Add fields to the create view.
81
+     *
82
+     * @param $modelData
83
+     *
84
+     * @return $this
85
+     */
86
+    private function addFields($modelData)
87
+    {
88
+        $fields = '';
89
+        $firstIteration = true;
90 90
 
91
-		foreach ($modelData->fields as $field)
92
-		{
93
-			if ($firstIteration)
94
-			{
95
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
-				$firstIteration = false;
97
-			}
98
-			else
99
-			{
100
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
-			}
102
-		}
91
+        foreach ($modelData->fields as $field)
92
+        {
93
+            if ($firstIteration)
94
+            {
95
+                $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
+                $firstIteration = false;
97
+            }
98
+            else
99
+            {
100
+                $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
+            }
102
+        }
103 103
 
104
-		$this->stub = str_replace('{{fields}}', $fields, $this->stub);
104
+        $this->stub = str_replace('{{fields}}', $fields, $this->stub);
105 105
 
106
-		return $this;
107
-	}
106
+        return $this;
107
+    }
108 108
 
109
-	/**
110
-	 * Replace the prefix.
111
-	 *
112
-	 * @param $prefix
113
-	 *
114
-	 * @return $this
115
-	 */
116
-	private function replaceRoutePrefix($prefix)
117
-	{
118
-		$this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
109
+    /**
110
+     * Replace the prefix.
111
+     *
112
+     * @param $prefix
113
+     *
114
+     * @return $this
115
+     */
116
+    private function replaceRoutePrefix($prefix)
117
+    {
118
+        $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
119 119
 
120
-		return $this;
121
-	}
120
+        return $this;
121
+    }
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29 29
 	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
30
+		if (File::exists(base_path('scaffolder-config/cache/view_create_'.$hash.self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33 33
 		}
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
57 57
 	{
58
-		$folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
58
+		$folder = PathParser::parse($scaffolderConfig->paths->views).strtolower($modelName);
59 59
 		
60 60
 		// create folder directory
61 61
 		Directory::createIfNotExists($folder, 0755, true);
62 62
 
63
-		$path = $folder  . '/create.blade.php';
63
+		$path = $folder.'/create.blade.php';
64 64
 
65 65
 		// Store in cache
66 66
 		if ($fileToCompile->cached)
67 67
 		{
68
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
68
+			File::copy(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $path);
69 69
 		}
70 70
 		else
71 71
 		{
72
-			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73
-			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
72
+			File::put(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $compiled);
73
+			File::copy(base_path('scaffolder-config/cache/view_create_'.$fileToCompile->hash.self::CACHE_EXT), $path);
74 74
 		}
75 75
 
76 76
 		return $path;
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 		{
93 93
 			if ($firstIteration)
94 94
 			{
95
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
95
+				$fields .= sprintf(self::getInputFor($field).PHP_EOL, $field->name);
96 96
 				$firstIteration = false;
97 97
 			}
98 98
 			else
99 99
 			{
100
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
100
+				$fields .= sprintf("\t".self::getInputFor($field).PHP_EOL, $field->name);
101 101
 			}
102 102
 		}
103 103
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
33
+		} else
35 34
 		{
36 35
 			$this->stub = $stub;
37 36
 
@@ -66,8 +65,7 @@  discard block
 block discarded – undo
66 65
 		if ($fileToCompile->cached)
67 66
 		{
68 67
 			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
-		}
70
-		else
68
+		} else
71 69
 		{
72 70
 			File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
73 71
 			File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
 			{
95 93
 				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96 94
 				$firstIteration = false;
97
-			}
98
-			else
95
+			} else
99 96
 			{
100 97
 				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101 98
 			}
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/View/EditViewCompiler.php 3 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -11,136 +11,136 @@
 block discarded – undo
11 11
 
12 12
 class EditViewCompiler extends AbstractViewCompiler
13 13
 {
14
-	use InputTypeResolverTrait;
15
-
16
-	/**
17
-	 * Compiles the edit view.
18
-	 *
19
-	 * @param      $stub
20
-	 * @param      $modelName
21
-	 * @param      $modelData
22
-	 * @param      $scaffolderConfig
23
-	 * @param      $hash
24
-	 * @param null $extra
25
-	 *
26
-	 * @return string
27
-	 */
28
-	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
-	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31
-		{
32
-			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
35
-		{
36
-			$this->stub = $stub;
37
-
38
-			return $this->replaceClassName($modelName)
39
-				->replaceBreadcrumb($modelName)
40
-				->addFields($modelData)
41
-				->replacePrimaryKey($modelData)
42
-				->replaceRoutePrefix($scaffolderConfig->routing->prefix)
43
-				->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
44
-		}
45
-	}
46
-
47
-	/**
48
-	 * Store the compiled stub.
49
-	 *
50
-	 * @param               $modelName
51
-	 * @param               $scaffolderConfig
52
-	 * @param               $compiled
53
-	 * @param FileToCompile $fileToCompile
54
-	 *
55
-	 * @return string
56
-	 */
57
-	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58
-	{
59
-		$folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
14
+    use InputTypeResolverTrait;
15
+
16
+    /**
17
+     * Compiles the edit view.
18
+     *
19
+     * @param      $stub
20
+     * @param      $modelName
21
+     * @param      $modelData
22
+     * @param      $scaffolderConfig
23
+     * @param      $hash
24
+     * @param null $extra
25
+     *
26
+     * @return string
27
+     */
28
+    public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29
+    {
30
+        if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31
+        {
32
+            return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
+        }
34
+        else
35
+        {
36
+            $this->stub = $stub;
37
+
38
+            return $this->replaceClassName($modelName)
39
+                ->replaceBreadcrumb($modelName)
40
+                ->addFields($modelData)
41
+                ->replacePrimaryKey($modelData)
42
+                ->replaceRoutePrefix($scaffolderConfig->routing->prefix)
43
+                ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash));
44
+        }
45
+    }
46
+
47
+    /**
48
+     * Store the compiled stub.
49
+     *
50
+     * @param               $modelName
51
+     * @param               $scaffolderConfig
52
+     * @param               $compiled
53
+     * @param FileToCompile $fileToCompile
54
+     *
55
+     * @return string
56
+     */
57
+    protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58
+    {
59
+        $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
60 60
 		
61
-		// create folder directory
62
-		Directory::createIfNotExists($folder, 0755, true);
63
-
64
-		$path   = $folder . '/edit.blade.php';
65
-
66
-		// Store in cache
67
-		if ($fileToCompile->cached)
68
-		{
69
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
-		}
71
-		else
72
-		{
73
-			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
75
-		}
76
-
77
-		return $path;
78
-	}
79
-
80
-	/**
81
-	 * Add fields to the edit view.
82
-	 *
83
-	 * @param $modelData
84
-	 *
85
-	 * @return $this
86
-	 */
87
-	private function addFields($modelData)
88
-	{
89
-		$fields = '';
90
-		$firstIteration = true;
91
-
92
-		foreach ($modelData->fields as $field)
93
-		{
94
-			if ($firstIteration)
95
-			{
96
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97
-				$firstIteration = false;
98
-			}
99
-			else
100
-			{
101
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102
-			}
103
-		}
104
-
105
-		$this->stub = str_replace('{{fields}}', $fields, $this->stub);
106
-
107
-		return $this;
108
-	}
109
-
110
-	/**
111
-	 * Replace the prefix.
112
-	 *
113
-	 * @param $prefix
114
-	 *
115
-	 * @return $this
116
-	 */
117
-	private function replaceRoutePrefix($prefix)
118
-	{
119
-		$this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
120
-
121
-		return $this;
122
-	}
123
-
124
-	/**
125
-	 * Replace the primary key.
126
-	 *
127
-	 * @param $modelData
128
-	 */
129
-	private function replacePrimaryKey($modelData)
130
-	{
131
-		$primaryKey = 'id';
132
-
133
-		foreach ($modelData->fields as $field)
134
-		{
135
-			if ($field->index == 'primary')
136
-			{
137
-				$primaryKey = $field->name;
138
-				break;
139
-			}
140
-		}
141
-
142
-		$this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub);
143
-
144
-		return $this;
145
-	}
61
+        // create folder directory
62
+        Directory::createIfNotExists($folder, 0755, true);
63
+
64
+        $path   = $folder . '/edit.blade.php';
65
+
66
+        // Store in cache
67
+        if ($fileToCompile->cached)
68
+        {
69
+            File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
+        }
71
+        else
72
+        {
73
+            File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
+            File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
75
+        }
76
+
77
+        return $path;
78
+    }
79
+
80
+    /**
81
+     * Add fields to the edit view.
82
+     *
83
+     * @param $modelData
84
+     *
85
+     * @return $this
86
+     */
87
+    private function addFields($modelData)
88
+    {
89
+        $fields = '';
90
+        $firstIteration = true;
91
+
92
+        foreach ($modelData->fields as $field)
93
+        {
94
+            if ($firstIteration)
95
+            {
96
+                $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97
+                $firstIteration = false;
98
+            }
99
+            else
100
+            {
101
+                $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102
+            }
103
+        }
104
+
105
+        $this->stub = str_replace('{{fields}}', $fields, $this->stub);
106
+
107
+        return $this;
108
+    }
109
+
110
+    /**
111
+     * Replace the prefix.
112
+     *
113
+     * @param $prefix
114
+     *
115
+     * @return $this
116
+     */
117
+    private function replaceRoutePrefix($prefix)
118
+    {
119
+        $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub);
120
+
121
+        return $this;
122
+    }
123
+
124
+    /**
125
+     * Replace the primary key.
126
+     *
127
+     * @param $modelData
128
+     */
129
+    private function replacePrimaryKey($modelData)
130
+    {
131
+        $primaryKey = 'id';
132
+
133
+        foreach ($modelData->fields as $field)
134
+        {
135
+            if ($field->index == 'primary')
136
+            {
137
+                $primaryKey = $field->name;
138
+                break;
139
+            }
140
+        }
141
+
142
+        $this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub);
143
+
144
+        return $this;
145
+    }
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null)
29 29
 	{
30
-		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
30
+		if (File::exists(base_path('scaffolder-config/cache/view_edit_'.$hash.self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33 33
 		}
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
58 58
 	{
59
-		$folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ;
59
+		$folder = PathParser::parse($scaffolderConfig->paths->views).strtolower($modelName);
60 60
 		
61 61
 		// create folder directory
62 62
 		Directory::createIfNotExists($folder, 0755, true);
63 63
 
64
-		$path   = $folder . '/edit.blade.php';
64
+		$path = $folder.'/edit.blade.php';
65 65
 
66 66
 		// Store in cache
67 67
 		if ($fileToCompile->cached)
68 68
 		{
69
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
69
+			File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path);
70 70
 		}
71 71
 		else
72 72
 		{
73
-			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74
-			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
73
+			File::put(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $compiled);
74
+			File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path);
75 75
 		}
76 76
 
77 77
 		return $path;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 		{
94 94
 			if ($firstIteration)
95 95
 			{
96
-				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
96
+				$fields .= sprintf(self::getInputFor($field).PHP_EOL, $field->name);
97 97
 				$firstIteration = false;
98 98
 			}
99 99
 			else
100 100
 			{
101
-				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
101
+				$fields .= sprintf("\t".self::getInputFor($field).PHP_EOL, $field->name);
102 102
 			}
103 103
 		}
104 104
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
33
+		} else
35 34
 		{
36 35
 			$this->stub = $stub;
37 36
 
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
 		if ($fileToCompile->cached)
68 67
 		{
69 68
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
-		}
71
-		else
69
+		} else
72 70
 		{
73 71
 			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74 72
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
 			{
96 94
 				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97 95
 				$firstIteration = false;
98
-			}
99
-			else
96
+			} else
100 97
 			{
101 98
 				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102 99
 			}
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/AbstractCompiler.php 3 patches
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -9,266 +9,266 @@
 block discarded – undo
9 9
 
10 10
 abstract class AbstractCompiler
11 11
 {
12
-	protected $cachePrefix ;
13
-	protected $stubFilename;
14
-
15
-	protected $stub;
16
-	protected $scaffolderConfig ;
17
-	protected $modelName ;
18
-	protected $modelData ;
19
-	protected $stubsDirectory ;
20
-
21
-	protected $eagerTable ;
22
-
23
-	const CACHE_EXT = '.scf';
24
-
25
-	public function __construct($scaffolderConfig, $modelData = null)
26
-	{
27
-		$this->modelName = isset($modelData->modelName) ? $modelData->modelName : null  ;
28
-		$this->modelData = $modelData ;
29
-		$this->scaffolderConfig = $scaffolderConfig ;
30
-
31
-		$this->stub = File::get($this->stubsDirectory . $this->stubFilename );
32
-	}
33
-
34
-	/**
35
-	 * Compiles .
36
-	 *
37
-	 * @param null $extra
38
-	 *
39
-	 * @return string
40
-	 */
41
-	public function compile($extra = null)
42
-	{
43
-		if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . $this->modelData->modelHash . self::CACHE_EXT)))
44
-		{
45
-			return $this->store(new FileToCompile(true, $this->modelData->modelHash));
46
-		}
47
-		else
48
-		{
49
-
50
-			return $this->replacePrimaryKey()
51
-						->replaceClassName()
52
-						->replaceTableName()
53
-						->replaceRoutePrefix()
54
-						->replaceAndStore();
55
-		}
56
-	}
57
-
58
-	/**
59
-	 * Replace and store the Stub.
60
-	 *
61
-	 * @return string
62
-	 */
63
-	abstract protected function replaceAndStore();
64
-
65
-	/**
66
-	 * Store the compiled stub.
67
-	 *
68
-	 * @param string $eagerTable
69
-	 *
70
-	 * @return string
71
-	 */
72
-	protected function setEagerTable($eagerTable){
73
-		$this->eagerTable = $eagerTable.'.';
74
-	}
75
-
76
-	/**
77
-	 * Store the compiled stub.
78
-	 *
79
-	 * @param FileToCompile $fileToCompile
80
-	 *
81
-	 * @return string
82
-	 */
83
-	protected function store(FileToCompile $fileToCompile)
84
-	{
85
-		$path = $this->getOutputFilename();
86
-
87
-		// Store in cache
88
-		if ($fileToCompile->cached)
89
-		{
90
-			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
91
-		}
92
-		else
93
-		{
94
-			File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub);
95
-			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
96
-		}
97
-
98
-		return $path;
99
-	}
100
-
101
-	/**
102
-	 * Get output filename
103
-	 *
104
-	 *
105
-	 * @return $this
106
-	 */
107
-	abstract protected function getOutputFilename();
108
-
109
-	/**
110
-	 * Replace the primary key.
111
-	 *
112
-	 * @param $this->modelData
113
-	 */
114
-	protected function replacePrimaryKey()
115
-	{
12
+    protected $cachePrefix ;
13
+    protected $stubFilename;
14
+
15
+    protected $stub;
16
+    protected $scaffolderConfig ;
17
+    protected $modelName ;
18
+    protected $modelData ;
19
+    protected $stubsDirectory ;
20
+
21
+    protected $eagerTable ;
22
+
23
+    const CACHE_EXT = '.scf';
24
+
25
+    public function __construct($scaffolderConfig, $modelData = null)
26
+    {
27
+        $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null  ;
28
+        $this->modelData = $modelData ;
29
+        $this->scaffolderConfig = $scaffolderConfig ;
30
+
31
+        $this->stub = File::get($this->stubsDirectory . $this->stubFilename );
32
+    }
33
+
34
+    /**
35
+     * Compiles .
36
+     *
37
+     * @param null $extra
38
+     *
39
+     * @return string
40
+     */
41
+    public function compile($extra = null)
42
+    {
43
+        if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . $this->modelData->modelHash . self::CACHE_EXT)))
44
+        {
45
+            return $this->store(new FileToCompile(true, $this->modelData->modelHash));
46
+        }
47
+        else
48
+        {
49
+
50
+            return $this->replacePrimaryKey()
51
+                        ->replaceClassName()
52
+                        ->replaceTableName()
53
+                        ->replaceRoutePrefix()
54
+                        ->replaceAndStore();
55
+        }
56
+    }
57
+
58
+    /**
59
+     * Replace and store the Stub.
60
+     *
61
+     * @return string
62
+     */
63
+    abstract protected function replaceAndStore();
64
+
65
+    /**
66
+     * Store the compiled stub.
67
+     *
68
+     * @param string $eagerTable
69
+     *
70
+     * @return string
71
+     */
72
+    protected function setEagerTable($eagerTable){
73
+        $this->eagerTable = $eagerTable.'.';
74
+    }
75
+
76
+    /**
77
+     * Store the compiled stub.
78
+     *
79
+     * @param FileToCompile $fileToCompile
80
+     *
81
+     * @return string
82
+     */
83
+    protected function store(FileToCompile $fileToCompile)
84
+    {
85
+        $path = $this->getOutputFilename();
86
+
87
+        // Store in cache
88
+        if ($fileToCompile->cached)
89
+        {
90
+            File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
91
+        }
92
+        else
93
+        {
94
+            File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub);
95
+            File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
96
+        }
97
+
98
+        return $path;
99
+    }
100
+
101
+    /**
102
+     * Get output filename
103
+     *
104
+     *
105
+     * @return $this
106
+     */
107
+    abstract protected function getOutputFilename();
108
+
109
+    /**
110
+     * Replace the primary key.
111
+     *
112
+     * @param $this->modelData
113
+     */
114
+    protected function replacePrimaryKey()
115
+    {
116 116
 		
117
-		$primaryKey = $this->getPrimaryKeyField()->name;
118
-
119
-		$this->stub = str_replace('{{primary_key}}', $primaryKey, $this->stub);
120
-
121
-		return $this;
122
-	}
123
-
124
-	protected function getPrimaryKeyField(){
125
-		$primaryKey = new stdClass;
126
-		$primaryKey->name = "id" ;
127
-		$primaryKey->index = "primary" ;
128
-		$primaryKey->declared =  false ;
129
-		$primaryKey->type = new stdClass ;
130
-		$primaryKey->type->ui = 'label' ;
131
-		$primaryKey->type->db = 'integer' ;
132
-		$primaryKey->foreignKey = [];
133
-		$primaryKey->validations = "required" ;
134
-
135
-		foreach ($this->modelData->fields as $field)
136
-		{
137
-			if ($field->index == 'primary')
138
-			{
139
-				$primaryKey = $field ;
140
-				break;
141
-			}
142
-		}
143
-
144
-		return $primaryKey ;
145
-	}
146
-
147
-	/**
148
-	 * Replace the class name.
149
-	 *
150
-	 *
151
-	 * @return $this
152
-	 */
153
-	protected function replaceClassName()
154
-	{
155
-		$this->stub = str_replace('{{class_name}}', $this->modelName, $this->stub);
156
-		$this->stub = str_replace('{{class_name_lw}}', strtolower($this->modelName), $this->stub);
157
-
158
-		return $this;
159
-	}
160
-
161
-	/**
162
-	 * Replace the table name.
163
-	 *
164
-	 * @return $this
165
-	 */
166
-	protected function replaceTableName()
167
-	{
168
-		$this->stub = str_replace('{{table_name}}', $this->modelData->tableName, $this->stub);
169
-
170
-		return $this;
171
-	}
172
-
173
-	/**
174
-	 * Replace the namespace.
175
-	 *
176
-	 * @return $this
177
-	 */
178
-	protected function replaceNamespace()
179
-	{
180
-		$this->stub = str_replace('{{namespace}}', $this->scaffolderConfig->generator->namespaces->models, $this->stub);
181
-
182
-		return $this;
183
-	}
184
-
185
-	/**
186
-	 * Replace the foreign strings by field.
187
-	 *
188
-	 * @param stdClass $field
189
-	 * @param string $originalStubPart
190
-	 *
191
-	 * @return $this
192
-	 */
193
-	protected function replaceForeingStrings($field,  $originalStubPart){
194
-		$replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart);
195
-		$replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub);
196
-		$replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub);
197
-		$replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub);
198
-		$replaceStub = str_replace('{{field}}', $field->name, $replaceStub);
199
-
200
-		if(isset($this->scaffolderConfig->generator->namespaces))
201
-			$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
202
-
203
-		return $replaceStub;
117
+        $primaryKey = $this->getPrimaryKeyField()->name;
118
+
119
+        $this->stub = str_replace('{{primary_key}}', $primaryKey, $this->stub);
120
+
121
+        return $this;
122
+    }
123
+
124
+    protected function getPrimaryKeyField(){
125
+        $primaryKey = new stdClass;
126
+        $primaryKey->name = "id" ;
127
+        $primaryKey->index = "primary" ;
128
+        $primaryKey->declared =  false ;
129
+        $primaryKey->type = new stdClass ;
130
+        $primaryKey->type->ui = 'label' ;
131
+        $primaryKey->type->db = 'integer' ;
132
+        $primaryKey->foreignKey = [];
133
+        $primaryKey->validations = "required" ;
134
+
135
+        foreach ($this->modelData->fields as $field)
136
+        {
137
+            if ($field->index == 'primary')
138
+            {
139
+                $primaryKey = $field ;
140
+                break;
141
+            }
142
+        }
143
+
144
+        return $primaryKey ;
145
+    }
146
+
147
+    /**
148
+     * Replace the class name.
149
+     *
150
+     *
151
+     * @return $this
152
+     */
153
+    protected function replaceClassName()
154
+    {
155
+        $this->stub = str_replace('{{class_name}}', $this->modelName, $this->stub);
156
+        $this->stub = str_replace('{{class_name_lw}}', strtolower($this->modelName), $this->stub);
157
+
158
+        return $this;
159
+    }
160
+
161
+    /**
162
+     * Replace the table name.
163
+     *
164
+     * @return $this
165
+     */
166
+    protected function replaceTableName()
167
+    {
168
+        $this->stub = str_replace('{{table_name}}', $this->modelData->tableName, $this->stub);
169
+
170
+        return $this;
171
+    }
172
+
173
+    /**
174
+     * Replace the namespace.
175
+     *
176
+     * @return $this
177
+     */
178
+    protected function replaceNamespace()
179
+    {
180
+        $this->stub = str_replace('{{namespace}}', $this->scaffolderConfig->generator->namespaces->models, $this->stub);
181
+
182
+        return $this;
183
+    }
184
+
185
+    /**
186
+     * Replace the foreign strings by field.
187
+     *
188
+     * @param stdClass $field
189
+     * @param string $originalStubPart
190
+     *
191
+     * @return $this
192
+     */
193
+    protected function replaceForeingStrings($field,  $originalStubPart){
194
+        $replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart);
195
+        $replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub);
196
+        $replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub);
197
+        $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub);
198
+        $replaceStub = str_replace('{{field}}', $field->name, $replaceStub);
199
+
200
+        if(isset($this->scaffolderConfig->generator->namespaces))
201
+            $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
202
+
203
+        return $replaceStub;
204 204
 		
205
-	}
206
-
207
-	/**
208
-	 * Replace the fields strings by field.
209
-	 *
210
-	 * @param stdClass $field
211
-	 * @param string $originalStubPart
212
-	 *
213
-	 * @return $this
214
-	 */
215
-	protected function replaceFieldStrings($field,  $originalStubPart){
216
-		$replaceStub = str_replace('{{field}}', $field->name, $originalStubPart);
205
+    }
206
+
207
+    /**
208
+     * Replace the fields strings by field.
209
+     *
210
+     * @param stdClass $field
211
+     * @param string $originalStubPart
212
+     *
213
+     * @return $this
214
+     */
215
+    protected function replaceFieldStrings($field,  $originalStubPart){
216
+        $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart);
217 217
 		
218
-		if($this->eagerTable) $this->eagerTable.'.' ;
218
+        if($this->eagerTable) $this->eagerTable.'.' ;
219 219
 
220
-		$replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub);
220
+        $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub);
221 221
 
222
-		return $replaceStub;
222
+        return $replaceStub;
223 223
 		
224
-	}
225
-
226
-	/**
227
-	 * Replace the prefix.
228
-	 *
229
-	 * @return $this
230
-	 */
231
-	protected function replaceRoutePrefix()
232
-	{
233
-		$this->stub = str_replace('{{route_prefix}}', $this->scaffolderConfig->generator->routing->prefix, $this->stub);
234
-
235
-		return $this;
236
-	}
237
-
238
-	/**
239
-	 * get anoter model data
240
-	 *
241
-	 * @param string $tableName
242
-	 *
243
-	 * @return $this
244
-	 */
245
-	protected $modelDataArray = [];
246
-	protected function getModelData($tableName){
224
+    }
225
+
226
+    /**
227
+     * Replace the prefix.
228
+     *
229
+     * @return $this
230
+     */
231
+    protected function replaceRoutePrefix()
232
+    {
233
+        $this->stub = str_replace('{{route_prefix}}', $this->scaffolderConfig->generator->routing->prefix, $this->stub);
234
+
235
+        return $this;
236
+    }
237
+
238
+    /**
239
+     * get anoter model data
240
+     *
241
+     * @param string $tableName
242
+     *
243
+     * @return $this
244
+     */
245
+    protected $modelDataArray = [];
246
+    protected function getModelData($tableName){
247 247
 		
248
-		if(array_key_exists($tableName, $this->modelDataArray)){
249
-			return $this->modelDataArray[$tableName];
250
-		}
251
-		else {
248
+        if(array_key_exists($tableName, $this->modelDataArray)){
249
+            return $this->modelDataArray[$tableName];
250
+        }
251
+        else {
252 252
 
253
-			$modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ;
253
+            $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ;
254 254
 
255
-			$modelData = Json::decodeFile($modelFilename);
255
+            $modelData = Json::decodeFile($modelFilename);
256 256
 
257
-			// Get model name
258
-			$modelName = ucwords($tableName);
257
+            // Get model name
258
+            $modelName = ucwords($tableName);
259 259
 
260
-			// Get model hash
261
-			$modelHash = md5_file($modelFilename);
260
+            // Get model hash
261
+            $modelHash = md5_file($modelFilename);
262 262
 
263
-			// Set model name
264
-			$modelData->modelName = $modelName ;
263
+            // Set model name
264
+            $modelData->modelName = $modelName ;
265 265
 
266
-			// Set model name
267
-			$modelData->modelHash = $modelHash ;
266
+            // Set model name
267
+            $modelData->modelHash = $modelHash ;
268 268
 
269
-			$this->modelDataArray[$tableName] = $modelData;
269
+            $this->modelDataArray[$tableName] = $modelData;
270 270
 
271
-			return $this->modelDataArray[$tableName];
272
-		}
273
-	}
271
+            return $this->modelDataArray[$tableName];
272
+        }
273
+    }
274 274
 }
275 275
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  discard block
 block discarded – undo
5 5
 use Scaffolder\Compilers\Support\FileToCompile;
6 6
 use Illuminate\Support\Facades\File;
7 7
 use Scaffolder\Support\Json;
8
-use stdClass ;
8
+use stdClass;
9 9
 
10 10
 abstract class AbstractCompiler
11 11
 {
12
-	protected $cachePrefix ;
12
+	protected $cachePrefix;
13 13
 	protected $stubFilename;
14 14
 
15 15
 	protected $stub;
16
-	protected $scaffolderConfig ;
17
-	protected $modelName ;
18
-	protected $modelData ;
19
-	protected $stubsDirectory ;
16
+	protected $scaffolderConfig;
17
+	protected $modelName;
18
+	protected $modelData;
19
+	protected $stubsDirectory;
20 20
 
21
-	protected $eagerTable ;
21
+	protected $eagerTable;
22 22
 
23 23
 	const CACHE_EXT = '.scf';
24 24
 
25 25
 	public function __construct($scaffolderConfig, $modelData = null)
26 26
 	{
27
-		$this->modelName = isset($modelData->modelName) ? $modelData->modelName : null  ;
28
-		$this->modelData = $modelData ;
29
-		$this->scaffolderConfig = $scaffolderConfig ;
27
+		$this->modelName = isset($modelData->modelName) ? $modelData->modelName : null;
28
+		$this->modelData = $modelData;
29
+		$this->scaffolderConfig = $scaffolderConfig;
30 30
 
31
-		$this->stub = File::get($this->stubsDirectory . $this->stubFilename );
31
+		$this->stub = File::get($this->stubsDirectory.$this->stubFilename);
32 32
 	}
33 33
 
34 34
 	/**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function compile($extra = null)
42 42
 	{
43
-		if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . $this->modelData->modelHash . self::CACHE_EXT)))
43
+		if (File::exists(base_path('scaffolder-config/cache/'.$this->cachePrefix.$this->modelData->modelHash.self::CACHE_EXT)))
44 44
 		{
45 45
 			return $this->store(new FileToCompile(true, $this->modelData->modelHash));
46 46
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return string
71 71
 	 */
72
-	protected function setEagerTable($eagerTable){
72
+	protected function setEagerTable($eagerTable) {
73 73
 		$this->eagerTable = $eagerTable.'.';
74 74
 	}
75 75
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 		// Store in cache
88 88
 		if ($fileToCompile->cached)
89 89
 		{
90
-			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
90
+			File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path);
91 91
 		}
92 92
 		else
93 93
 		{
94
-			File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub);
95
-			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
94
+			File::put(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $this->stub);
95
+			File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path);
96 96
 		}
97 97
 
98 98
 		return $path;
@@ -121,27 +121,27 @@  discard block
 block discarded – undo
121 121
 		return $this;
122 122
 	}
123 123
 
124
-	protected function getPrimaryKeyField(){
124
+	protected function getPrimaryKeyField() {
125 125
 		$primaryKey = new stdClass;
126
-		$primaryKey->name = "id" ;
127
-		$primaryKey->index = "primary" ;
128
-		$primaryKey->declared =  false ;
129
-		$primaryKey->type = new stdClass ;
130
-		$primaryKey->type->ui = 'label' ;
131
-		$primaryKey->type->db = 'integer' ;
126
+		$primaryKey->name = "id";
127
+		$primaryKey->index = "primary";
128
+		$primaryKey->declared = false;
129
+		$primaryKey->type = new stdClass;
130
+		$primaryKey->type->ui = 'label';
131
+		$primaryKey->type->db = 'integer';
132 132
 		$primaryKey->foreignKey = [];
133
-		$primaryKey->validations = "required" ;
133
+		$primaryKey->validations = "required";
134 134
 
135 135
 		foreach ($this->modelData->fields as $field)
136 136
 		{
137 137
 			if ($field->index == 'primary')
138 138
 			{
139
-				$primaryKey = $field ;
139
+				$primaryKey = $field;
140 140
 				break;
141 141
 			}
142 142
 		}
143 143
 
144
-		return $primaryKey ;
144
+		return $primaryKey;
145 145
 	}
146 146
 
147 147
 	/**
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return $this
192 192
 	 */
193
-	protected function replaceForeingStrings($field,  $originalStubPart){
193
+	protected function replaceForeingStrings($field, $originalStubPart) {
194 194
 		$replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart);
195 195
 		$replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub);
196 196
 		$replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub);
197 197
 		$replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub);
198 198
 		$replaceStub = str_replace('{{field}}', $field->name, $replaceStub);
199 199
 
200
-		if(isset($this->scaffolderConfig->generator->namespaces))
200
+		if (isset($this->scaffolderConfig->generator->namespaces))
201 201
 			$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
202 202
 
203 203
 		return $replaceStub;
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return $this
214 214
 	 */
215
-	protected function replaceFieldStrings($field,  $originalStubPart){
215
+	protected function replaceFieldStrings($field, $originalStubPart) {
216 216
 		$replaceStub = str_replace('{{field}}', $field->name, $originalStubPart);
217 217
 		
218
-		if($this->eagerTable) $this->eagerTable.'.' ;
218
+		if ($this->eagerTable) $this->eagerTable.'.';
219 219
 
220 220
 		$replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub);
221 221
 
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 	 * @return $this
244 244
 	 */
245 245
 	protected $modelDataArray = [];
246
-	protected function getModelData($tableName){
246
+	protected function getModelData($tableName) {
247 247
 		
248
-		if(array_key_exists($tableName, $this->modelDataArray)){
248
+		if (array_key_exists($tableName, $this->modelDataArray)) {
249 249
 			return $this->modelDataArray[$tableName];
250 250
 		}
251 251
 		else {
252 252
 
253
-			$modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ;
253
+			$modelFilename = base_path('scaffolder-config/models/').$tableName.'.json';
254 254
 
255 255
 			$modelData = Json::decodeFile($modelFilename);
256 256
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 			$modelHash = md5_file($modelFilename);
262 262
 
263 263
 			// Set model name
264
-			$modelData->modelName = $modelName ;
264
+			$modelData->modelName = $modelName;
265 265
 
266 266
 			// Set model name
267
-			$modelData->modelHash = $modelHash ;
267
+			$modelData->modelHash = $modelHash;
268 268
 
269 269
 			$this->modelDataArray[$tableName] = $modelData;
270 270
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 		if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . $this->modelData->modelHash . self::CACHE_EXT)))
44 44
 		{
45 45
 			return $this->store(new FileToCompile(true, $this->modelData->modelHash));
46
-		}
47
-		else
46
+		} else
48 47
 		{
49 48
 
50 49
 			return $this->replacePrimaryKey()
@@ -88,8 +87,7 @@  discard block
 block discarded – undo
88 87
 		if ($fileToCompile->cached)
89 88
 		{
90 89
 			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
91
-		}
92
-		else
90
+		} else
93 91
 		{
94 92
 			File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub);
95 93
 			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -197,8 +195,9 @@  discard block
 block discarded – undo
197 195
 		$replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub);
198 196
 		$replaceStub = str_replace('{{field}}', $field->name, $replaceStub);
199 197
 
200
-		if(isset($this->scaffolderConfig->generator->namespaces))
201
-			$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
198
+		if(isset($this->scaffolderConfig->generator->namespaces)) {
199
+					$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
200
+		}
202 201
 
203 202
 		return $replaceStub;
204 203
 		
@@ -215,7 +214,9 @@  discard block
 block discarded – undo
215 214
 	protected function replaceFieldStrings($field,  $originalStubPart){
216 215
 		$replaceStub = str_replace('{{field}}', $field->name, $originalStubPart);
217 216
 		
218
-		if($this->eagerTable) $this->eagerTable.'.' ;
217
+		if($this->eagerTable) {
218
+		    $this->eagerTable.'.' ;
219
+		}
219 220
 
220 221
 		$replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub);
221 222
 
@@ -247,8 +248,7 @@  discard block
 block discarded – undo
247 248
 		
248 249
 		if(array_key_exists($tableName, $this->modelDataArray)){
249 250
 			return $this->modelDataArray[$tableName];
250
-		}
251
-		else {
251
+		} else {
252 252
 
253 253
 			$modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ;
254 254
 
Please login to merge, or discard this patch.