@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php namespace jlourenco\support\Database; |
2 | 2 | |
3 | -use Illuminate\Database\Connection; |
|
4 | -use Illuminate\Database\Schema\Blueprint as IlluminateBlueprint; |
|
5 | -use Illuminate\Database\Schema\Grammars\MySqlGrammar as IlluminateMySqlGrammar; |
|
3 | +use Illuminate\Database\Connection; |
|
4 | +use Illuminate\Database\Schema\Blueprint as IlluminateBlueprint; |
|
5 | +use Illuminate\Database\Schema\Grammars\MySqlGrammar as IlluminateMySqlGrammar; |
|
6 | 6 | use Illuminate\Support\Fluent; |
7 | 7 | |
8 | 8 | /** |
@@ -122,8 +122,7 @@ |
||
122 | 122 | if ( isset($command->length) ) |
123 | 123 | { |
124 | 124 | $column .= "({$command->length})"; |
125 | - } |
|
126 | - elseif ( 'string' == $blueprintColumn->type && $blueprintColumn->length > 255 ) |
|
125 | + } elseif ( 'string' == $blueprintColumn->type && $blueprintColumn->length > 255 ) |
|
127 | 126 | { |
128 | 127 | $column .= '(255)'; |
129 | 128 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct() |
15 | 15 | { |
16 | - if ( ! in_array('Collate', $this->modifiers) ) |
|
16 | + if (!in_array('Collate', $this->modifiers)) |
|
17 | 17 | { |
18 | 18 | array_splice($this->modifiers, array_search('Unsigned', $this->modifiers) + 1, 0, 'Collate'); |
19 | 19 | } |
20 | 20 | // new versions of Laravel already have comment modifier |
21 | - if ( ! in_array('Comment', $this->modifiers) ) |
|
21 | + if (!in_array('Comment', $this->modifiers)) |
|
22 | 22 | { |
23 | 23 | array_splice($this->modifiers, array_search('After', $this->modifiers) - 1, 0, 'Comment'); |
24 | 24 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function modifyCollate(IlluminateBlueprint $blueprint, Fluent $column) |
35 | 35 | { |
36 | - if ( ! is_null($column->collate) ) |
|
36 | + if (!is_null($column->collate)) |
|
37 | 37 | { |
38 | 38 | $characterSet = strtok($column->collate, '_'); |
39 | 39 | return " character set $characterSet collate {$column->collate}"; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function modifyComment(IlluminateBlueprint $blueprint, Fluent $column) |
51 | 51 | { |
52 | - if ( ! is_null($column->comment) ) |
|
52 | + if (!is_null($column->comment)) |
|
53 | 53 | { |
54 | 54 | $comment = str_replace("'", "\'", $column->comment); |
55 | 55 | return " comment '$comment'"; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $sql = parent::compileCreate($blueprint, $command, $connection); |
70 | 70 | // Table annotation support |
71 | - if ( isset($blueprint->comment) ) |
|
71 | + if (isset($blueprint->comment)) |
|
72 | 72 | { |
73 | 73 | $comment = str_replace("'", "\'", $blueprint->comment); |
74 | 74 | $sql .= " comment = '$comment'"; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function typeSet(Fluent $column) |
97 | 97 | { |
98 | - return "set('" . implode("', '", $column->allowed) . "')"; |
|
98 | + return "set('".implode("', '", $column->allowed)."')"; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | protected function compileKey(IlluminateBlueprint $blueprint, Fluent $command, $type) |
110 | 110 | { |
111 | 111 | $columns = []; |
112 | - foreach($command->columns as $commandColumn) |
|
112 | + foreach ($command->columns as $commandColumn) |
|
113 | 113 | { |
114 | - foreach($blueprint->getColumns() as $blueprintColumn) |
|
114 | + foreach ($blueprint->getColumns() as $blueprintColumn) |
|
115 | 115 | { |
116 | - if ( $blueprintColumn->name != $commandColumn ) |
|
116 | + if ($blueprintColumn->name != $commandColumn) |
|
117 | 117 | { |
118 | 118 | continue; |
119 | 119 | } |
120 | 120 | |
121 | 121 | $column = $this->wrap($commandColumn); |
122 | - if ( isset($command->length) ) |
|
122 | + if (isset($command->length)) |
|
123 | 123 | { |
124 | 124 | $column .= "({$command->length})"; |
125 | 125 | } |
126 | - elseif ( 'string' == $blueprintColumn->type && $blueprintColumn->length > 255 ) |
|
126 | + elseif ('string' == $blueprintColumn->type && $blueprintColumn->length > 255) |
|
127 | 127 | { |
128 | 128 | $column .= '(255)'; |
129 | 129 | } |
@@ -15,10 +15,11 @@ |
||
15 | 15 | $recaptcha = new ReCaptcha($secret); |
16 | 16 | $resp = $recaptcha->verify($response, $remoteip); |
17 | 17 | |
18 | - if ($resp->isSuccess()) |
|
19 | - return true; |
|
20 | - else |
|
21 | - return false; |
|
18 | + if ($resp->isSuccess()) { |
|
19 | + return true; |
|
20 | + } else { |
|
21 | + return false; |
|
22 | + } |
|
22 | 23 | } |
23 | 24 | |
24 | 25 | } |
25 | 26 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | // create a event to happen on deleting |
16 | - static::deleting(function($table) { |
|
16 | + static::deleting(function($table) { |
|
17 | 17 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
18 | 18 | $table->deleted_by = Sentinel::getUser()->id; |
19 | 19 | else |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | }); |
24 | 24 | |
25 | 25 | // create a event to happen on saving |
26 | - static::saving(function($table) { |
|
26 | + static::saving(function($table) { |
|
27 | 27 | |
28 | 28 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
29 | 29 | { |
@@ -14,10 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | // create a event to happen on deleting |
16 | 16 | static::deleting(function($table) { |
17 | - if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
|
18 | - $table->deleted_by = Sentinel::getUser()->id; |
|
19 | - else |
|
20 | - $table->deleted_by = Auth::user()->id; |
|
17 | + if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) { |
|
18 | + $table->deleted_by = Sentinel::getUser()->id; |
|
19 | + } else { |
|
20 | + $table->deleted_by = Auth::user()->id; |
|
21 | + } |
|
21 | 22 | |
22 | 23 | $table->update(['deleted_by' => $table->deleted_by]); |
23 | 24 | }); |
@@ -27,19 +28,22 @@ discard block |
||
27 | 28 | |
28 | 29 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
29 | 30 | { |
30 | - if (Sentinel::check()) |
|
31 | - $table->modified_by = Sentinel::getUser()->id; |
|
32 | - |
|
33 | - if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) |
|
34 | - $table->created_by = Sentinel::getUser()->id; |
|
35 | - } |
|
36 | - else |
|
31 | + if (Sentinel::check()) { |
|
32 | + $table->modified_by = Sentinel::getUser()->id; |
|
33 | + } |
|
34 | + |
|
35 | + if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) { |
|
36 | + $table->created_by = Sentinel::getUser()->id; |
|
37 | + } |
|
38 | + } else |
|
37 | 39 | { |
38 | - if (!Auth::guest()) |
|
39 | - $table->modified_by = Auth::user()->id; |
|
40 | + if (!Auth::guest()) { |
|
41 | + $table->modified_by = Auth::user()->id; |
|
42 | + } |
|
40 | 43 | |
41 | - if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) |
|
42 | - $table->created_by = Auth::user()->id; |
|
44 | + if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) { |
|
45 | + $table->created_by = Auth::user()->id; |
|
46 | + } |
|
43 | 47 | } |
44 | 48 | |
45 | 49 | }); |
@@ -109,8 +109,9 @@ |
||
109 | 109 | // If no name was specified for this index, we will create one using a basic |
110 | 110 | // convention of the table name, followed by the columns, followed by an |
111 | 111 | // index type, such as primary or index, which makes the index unique. |
112 | - if (is_null($index)) |
|
113 | - $index = $this->createIndexName($type, $columns); |
|
112 | + if (is_null($index)) { |
|
113 | + $index = $this->createIndexName($type, $columns); |
|
114 | + } |
|
114 | 115 | return $this->addCommand($type, compact('index', 'columns', 'length')); |
115 | 116 | } |
116 | 117 |
@@ -90,7 +90,7 @@ |
||
90 | 90 | public function hasForeign($table, $foreign) |
91 | 91 | { |
92 | 92 | $sql = $this->grammar->compileHasForeign(); |
93 | - $table = $this->connection->getTablePrefix() . $table; |
|
93 | + $table = $this->connection->getTablePrefix().$table; |
|
94 | 94 | return count($this->connection->select($sql, [$table, $foreign])) > 0; |
95 | 95 | } |
96 | 96 |
@@ -57,8 +57,9 @@ discard block |
||
57 | 57 | return (!(stripos($var, 'jlourenco.') === false) && $var != 'jlourenco.php'); |
58 | 58 | }); |
59 | 59 | |
60 | - if ($fileExists) |
|
61 | - unlink($mainFile); |
|
60 | + if ($fileExists) { |
|
61 | + unlink($mainFile); |
|
62 | + } |
|
62 | 63 | |
63 | 64 | touch($mainFile); |
64 | 65 | |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | |
72 | 73 | while ($line = fgets($in)) |
73 | 74 | { |
74 | - if ((stripos($line, '<?php') === false) && (stripos($line, '];') === false) && (stripos($line, 'return [') === false)) |
|
75 | - $content .= $line; |
|
75 | + if ((stripos($line, '<?php') === false) && (stripos($line, '];') === false) && (stripos($line, 'return [') === false)) { |
|
76 | + $content .= $line; |
|
77 | + } |
|
76 | 78 | } |
77 | 79 | |
78 | 80 | fclose($in); |
@@ -84,8 +86,9 @@ discard block |
||
84 | 86 | |
85 | 87 | $bytesWritten = File::append($mainFile, $content); |
86 | 88 | |
87 | - if ($bytesWritten === false) |
|
88 | - $this->info('Couldn\'t write to config file.'); |
|
89 | + if ($bytesWritten === false) { |
|
90 | + $this->info('Couldn\'t write to config file.'); |
|
91 | + } |
|
89 | 92 | |
90 | 93 | $this->info('Config files compiled'); |
91 | 94 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | private function compileConfigFiles() |
51 | 51 | { |
52 | 52 | $path = base_path('/config'); |
53 | - $mainFile = $path . '/jlourenco.php'; |
|
53 | + $mainFile = $path.'/jlourenco.php'; |
|
54 | 54 | $fileExists = file_exists($mainFile); |
55 | 55 | |
56 | - $files = array_filter(scandir($path), function ($var) { |
|
56 | + $files = array_filter(scandir($path), function($var) { |
|
57 | 57 | return (!(stripos($var, 'jlourenco.') === false) && $var != 'jlourenco.php'); |
58 | 58 | }); |
59 | 59 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | foreach ($files as $file) |
69 | 69 | { |
70 | - $in = fopen($path . '/' . $file, "r"); |
|
70 | + $in = fopen($path.'/'.$file, "r"); |
|
71 | 71 | |
72 | 72 | while ($line = fgets($in)) |
73 | 73 | { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | fclose($in); |
79 | 79 | |
80 | - unlink($path . '/' . $file); |
|
80 | + unlink($path.'/'.$file); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $content .= "];\n"; |
@@ -1,11 +1,8 @@ |
||
1 | 1 | <?php namespace jlourenco\support\Commands; |
2 | 2 | |
3 | -use Illuminate\Console\Command; |
|
4 | -use Symfony\Component\Console\Input\InputOption; |
|
5 | -use Symfony\Component\Console\Input\InputArgument; |
|
6 | -use File; |
|
7 | -use jlourenco\support\Helpers\FileLoader; |
|
8 | -use Setting; |
|
3 | +use Illuminate\Console\Command; |
|
4 | +use File; |
|
5 | +use Setting; |
|
9 | 6 | use Schema; |
10 | 7 | |
11 | 8 | class SetupCommand extends Command { |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | // Normalize into a six character long hex string |
10 | 10 | $hex = str_replace('#', '', $hex); |
11 | 11 | if (strlen($hex) == 3) { |
12 | - $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2); |
|
12 | + $hex = str_repeat(substr($hex, 0, 1), 2).str_repeat(substr($hex, 1, 1), 2).str_repeat(substr($hex, 2, 1), 2); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | // Split into three parts: R, G and B |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | foreach ($color_parts as $color) { |
20 | 20 | $color = hexdec($color); // Convert to decimal |
21 | - $color = max(0,min(255,$color + $steps)); // Adjust color |
|
21 | + $color = max(0, min(255, $color + $steps)); // Adjust color |
|
22 | 22 | $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code |
23 | 23 | } |
24 | 24 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * Set the path to the file to use |
86 | 86 | * @param string $path The path to the file |
87 | - * @return \Philf\Setting\Setting |
|
87 | + * @return Setting |
|
88 | 88 | */ |
89 | 89 | public function path($path) |
90 | 90 | { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Set the filename to use |
96 | 96 | * @param string $filename The filename |
97 | - * @return \Philf\Setting\Setting |
|
97 | + * @return Setting |
|
98 | 98 | */ |
99 | 99 | public function filename($filename) |
100 | 100 | { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * Load the file in to $this->settings so values can be used immediately |
166 | 166 | * @param string $path The path to be used |
167 | 167 | * @param string $filename The filename to be used |
168 | - * @return \Philf\Setting\Setting |
|
168 | + * @return Setting |
|
169 | 169 | */ |
170 | 170 | public function load($path = null, $filename = null) |
171 | 171 | { |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | return $this->settings; |
115 | 115 | } |
116 | 116 | $ts = microtime(true); |
117 | - if($ts !== array_get($this->settings, $key, $ts)) |
|
117 | + if ($ts !== array_get($this->settings, $key, $ts)) |
|
118 | 118 | { |
119 | 119 | return array_get($this->settings, $key); |
120 | 120 | } |
121 | - if ( ! is_null($this->fallback) and $this->fallback->fallbackHas($key)) |
|
121 | + if (!is_null($this->fallback) and $this->fallback->fallbackHas($key)) |
|
122 | 122 | { |
123 | 123 | return $this->fallback->fallbackGet($key, $default); |
124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function set($key, $value) |
134 | 134 | { |
135 | - array_set($this->settings,$key,$value); |
|
135 | + array_set($this->settings, $key, $value); |
|
136 | 136 | $this->save($this->path, $this->filename); |
137 | 137 | $this->load($this->path, $this->filename); |
138 | 138 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function forget($deleteKey) |
145 | 145 | { |
146 | - array_forget($this->settings,$deleteKey); |
|
146 | + array_forget($this->settings, $deleteKey); |
|
147 | 147 | $this->save($this->path, $this->filename); |
148 | 148 | $this->load($this->path, $this->filename); |
149 | 149 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function has($searchKey) |
156 | 156 | { |
157 | 157 | $default = microtime(true); |
158 | - if($default == array_get($this->settings, $searchKey, $default) and !is_null($this->fallback)) |
|
158 | + if ($default == array_get($this->settings, $searchKey, $default) and !is_null($this->fallback)) |
|
159 | 159 | { |
160 | 160 | return $this->fallback->fallbackHas($searchKey); |
161 | 161 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $this->path = isset($path) ? $path : $this->path; |
193 | 193 | $this->filename = isset($filename) ? $filename : $this->filename; |
194 | - if ( ! file_exists($this->path)) |
|
194 | + if (!file_exists($this->path)) |
|
195 | 195 | { |
196 | 196 | mkdir($this->path, 0755, true); |
197 | 197 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | foreach ($data as $key => $value) |
218 | 218 | { |
219 | - array_set($this->settings,$key,$value); |
|
219 | + array_set($this->settings, $key, $value); |
|
220 | 220 | } |
221 | 221 | $this->save($this->path, $this->filename); |
222 | 222 | $this->load($this->path, $this->filename); |
@@ -174,8 +174,7 @@ |
||
174 | 174 | if (is_file($this->path.'/'.$this->filename)) |
175 | 175 | { |
176 | 176 | $this->settings = json_decode(file_get_contents($this->path.'/'.$this->filename), true); |
177 | - } |
|
178 | - else |
|
177 | + } else |
|
179 | 178 | { |
180 | 179 | $this->settings = array(); |
181 | 180 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | // Publish a config file |
51 | 51 | $this->publishes([ |
52 | - __DIR__ . '/config' => base_path('/config') |
|
52 | + __DIR__.'/config' => base_path('/config') |
|
53 | 53 | ], 'config'); |
54 | 54 | } |
55 | 55 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | protected function registerSetting() |
109 | 109 | { |
110 | - $this->app->singleton('setting', function ($app) { |
|
110 | + $this->app->singleton('setting', function($app) { |
|
111 | 111 | $config = $app['config']->get('jlourenco.support'); |
112 | 112 | |
113 | 113 | $path = array_get($config, 'Setting.path'); |
@@ -121,8 +121,9 @@ |
||
121 | 121 | |
122 | 122 | $config = $this->app['config']->get('jlourenco.support'); |
123 | 123 | |
124 | - if (array_get($config, 'Setting.autoAlias')) |
|
125 | - $this->app->alias('setting', 'jlourenco\support\Setting'); |
|
124 | + if (array_get($config, 'Setting.autoAlias')) { |
|
125 | + $this->app->alias('setting', 'jlourenco\support\Setting'); |
|
126 | + } |
|
126 | 127 | } |
127 | 128 | |
128 | 129 | /** |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | $file = (!$environment || ($environment == 'production')) ? "{$path}/{$group}.php" : "{$path}/{$environment}/{$group}.php"; |
14 | 14 | |
15 | - $this->files->put($file, '<?php return ' . var_export($items, true) . ';'); |
|
15 | + $this->files->put($file, '<?php return '.var_export($items, true).';'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -7,8 +7,9 @@ |
||
7 | 7 | { |
8 | 8 | $path = $this->getPath($namespace); |
9 | 9 | |
10 | - if (is_null($path)) |
|
11 | - return; |
|
10 | + if (is_null($path)) { |
|
11 | + return; |
|
12 | + } |
|
12 | 13 | |
13 | 14 | $file = (!$environment || ($environment == 'production')) ? "{$path}/{$group}.php" : "{$path}/{$environment}/{$group}.php"; |
14 | 15 |