Skip to content

Commit 49553f7

Browse files
authored
Merge pull request #2296 from z-song/analysis-8QKJMo
Apply fixes from StyleCI
2 parents d2854c2 + c4de149 commit 49553f7

File tree

11 files changed

+32
-27
lines changed

11 files changed

+32
-27
lines changed

src/Console/FormCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@ public function handle()
3131
$modelName = $this->option('model');
3232
if (empty($modelName) || !class_exists($modelName)) {
3333
$this->error('Model does not exists !');
34+
3435
return false;
3536
}
3637

3738
// use doctrine/dbal
3839
$model = $this->laravel->make($modelName);
39-
$table = $model->getConnection()->getTablePrefix() . $model->getTable();
40+
$table = $model->getConnection()->getTablePrefix().$model->getTable();
4041
$schema = $model->getConnection()->getDoctrineSchemaManager($table);
4142

4243
if (!method_exists($schema, 'getDatabasePlatform')) {
4344
$this->error('You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. ');
4445
$this->info('Using install command: composer require doctrine/dbal');
45-
return false;
4646

47+
return false;
4748
}
4849

4950
// custom mapping the types that doctrine/dbal does not support
@@ -110,10 +111,10 @@ public function handle()
110111
case $this->checkColumn($name, ['color', 'rgb']):
111112
$fieldType = 'color';
112113
break;
113-
case $this->checkColumn($name, ['image', 'img', 'avatar']) :
114+
case $this->checkColumn($name, ['image', 'img', 'avatar']):
114115
$fieldType = 'image';
115116
break;
116-
case $this->checkColumn($name, ['file', 'attachment']) :
117+
case $this->checkColumn($name, ['file', 'attachment']):
117118
$fieldType = 'file';
118119
break;
119120
default:
@@ -155,20 +156,19 @@ public function handle()
155156
// set column comment
156157
$comment = $comment ? $comment : $name;
157158

158-
159159
$adminForm .= "\$form->{$fieldType}('{$name}', '{$comment}')->default({$defaultValue});\n";
160160
}
161161
$this->alert("laravel-admin form filed generator for {$modelName}:");
162162
$this->info($adminForm);
163163
}
164-
165164
}
166165

167166
/**
168167
* Check if the table column contains the specified keywords of the array.
169168
*
170169
* @param string $haystack
171-
* @param array $needle
170+
* @param array $needle
171+
*
172172
* @return bool
173173
*/
174174
private function checkColumn(string $haystack, array $needle)
@@ -178,10 +178,10 @@ private function checkColumn(string $haystack, array $needle)
178178
return true;
179179
}
180180
}
181+
181182
return false;
182183
}
183184

184-
185185
/**
186186
* Get the console command options.
187187
*
@@ -191,7 +191,7 @@ protected function getOptions()
191191
{
192192
return [
193193
['model', null, InputOption::VALUE_REQUIRED,
194-
'The eloquent model that should be use as controller data source.',],
194+
'The eloquent model that should be use as controller data source.', ],
195195
];
196196
}
197197
}

src/Form.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ protected function redirectAfterStore()
548548
* Get RedirectResponse after update.
549549
*
550550
* @param mixed $key
551+
*
551552
* @return \Illuminate\Http\RedirectResponse
552553
*/
553554
protected function redirectAfterUpdate($key)
@@ -562,16 +563,17 @@ protected function redirectAfterUpdate($key)
562563
*
563564
* @param string $resourcesPath
564565
* @param string $key
566+
*
565567
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
566568
*/
567569
protected function redirectAfterSaving($resourcesPath, $key)
568570
{
569571
if (request('after-save') == 1) {
570572
// continue editing
571-
$url = rtrim($resourcesPath, '/') . "/{$key}/edit";
573+
$url = rtrim($resourcesPath, '/')."/{$key}/edit";
572574
} elseif (request('after-save') == 2) {
573575
// view resource
574-
$url = rtrim($resourcesPath, '/') . "/{$key}";
576+
$url = rtrim($resourcesPath, '/')."/{$key}";
575577
} else {
576578
$url = request(Builder::PREVIOUS_URL_KEY) ?: $resourcesPath;
577579
}

src/Form/Footer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Footer implements Renderable
99
{
1010
/**
11-
* Footer view
11+
* Footer view.
1212
*
1313
* @var string
1414
*/
@@ -67,7 +67,7 @@ public function disableSubmit()
6767
*/
6868
protected function setupScript()
6969
{
70-
$script = <<<EOT
70+
$script = <<<'EOT'
7171
$('.after-submit').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChecked', function () {
7272
$('.after-submit').not(this).iCheck('uncheck');
7373
});
@@ -92,4 +92,4 @@ public function render()
9292

9393
return view($this->view, $data)->render();
9494
}
95-
}
95+
}

src/Form/Tools.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ public function disableListButton()
280280
* Render custom tools.
281281
*
282282
* @param Collection $tools
283+
*
283284
* @return mixed
284285
*/
285286
protected function renderCustomTools($tools)

src/Grid/Displayers/Editable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Editable extends AbstractDisplayer
2424
* @var array
2525
*/
2626
protected $options = [
27-
'emptytext' => '<i class="fa fa-pencil"></i>'
27+
'emptytext' => '<i class="fa fa-pencil"></i>',
2828
];
2929

3030
/**

src/Grid/Filter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public function filters()
297297
/**
298298
* @param string $key
299299
* @param string $label
300+
*
300301
* @return mixed
301302
*/
302303
public function scope($key, $label = '')
@@ -432,6 +433,7 @@ public function urlWithoutScopes()
432433
* Get full url without query strings.
433434
*
434435
* @param Arrayable|array|string $keys
436+
*
435437
* @return string
436438
*/
437439
protected function fullUrlWithoutQuery($keys)

src/Grid/Filter/Scope.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Scope implements Renderable
2727

2828
/**
2929
* Scope constructor.
30+
*
3031
* @param $key
3132
* @param string $label
3233
*/
@@ -72,7 +73,7 @@ public function render()
7273

7374
/**
7475
* @param string $method
75-
* @param array $arguments
76+
* @param array $arguments
7677
*
7778
* @return $this
7879
*/
@@ -82,4 +83,4 @@ public function __call($method, $arguments)
8283

8384
return $this;
8485
}
85-
}
86+
}

src/Grid/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ public function __call($method, $arguments)
581581
* Set the relationships that should be eager loaded.
582582
*
583583
* @param mixed $relations
584+
*
584585
* @return $this|Model
585586
*/
586587
public function with($relations)
@@ -594,7 +595,6 @@ public function with($relations)
594595
}
595596

596597
if (is_string($relations)) {
597-
598598
if (Str::contains($relations, '.')) {
599599
$relations = explode('.', $relations)[0];
600600
}

src/Grid/Tools/FilterButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ public function render()
9797

9898
return view($this->view, $variables)->render();
9999
}
100-
}
100+
}

src/Show/Field.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Field implements Renderable
8282
'archive' => 'zip|tar\.gz|rar|rpm',
8383
'txt' => 'txt|pac|log|md',
8484
'audio' => 'mp3|wav|flac|3pg|aa|aac|ape|au|m4a|mpc|ogg',
85-
'video' => 'mkv|rmvb|flv|mp4|avi|wmv|rm|asf|mpeg'
85+
'video' => 'mkv|rmvb|flv|mp4|avi|wmv|rm|asf|mpeg',
8686
];
8787

8888
/**
@@ -209,15 +209,15 @@ public function image($server = '', $width = 200, $height = 200)
209209
* Show field as a file.
210210
*
211211
* @param string $server
212-
* @param bool $download
212+
* @param bool $download
213+
*
213214
* @return Field
214215
*/
215216
public function file($server = '', $download = true)
216217
{
217218
$field = $this;
218219

219220
return $this->as(function ($path) use ($server, $download, $field) {
220-
221221
$name = basename($path);
222222

223223
$field->wrapped = false;
@@ -232,7 +232,7 @@ public function file($server = '', $download = true)
232232
$storage = Storage::disk(config('admin.upload.disk'));
233233
if ($storage->exists($path)) {
234234
$url = $storage->url($path);
235-
$size = ($storage->size($path)/1000) . 'KB';
235+
$size = ($storage->size($path) / 1000).'KB';
236236
}
237237
}
238238

@@ -252,7 +252,6 @@ public function file($server = '', $download = true)
252252
</li>
253253
</ul>
254254
HTML;
255-
256255
});
257256
}
258257

@@ -323,11 +322,9 @@ public function json()
323322
$field = $this;
324323

325324
return $this->as(function ($value) use ($field) {
326-
327325
$content = json_decode($value, true);
328326

329327
if (json_last_error() == 0) {
330-
331328
$field->wrapped = false;
332329

333330
return '<pre><code>'.json_encode($content, JSON_PRETTY_PRINT).'</code></pre>';
@@ -338,9 +335,10 @@ public function json()
338335
}
339336

340337
/**
341-
* Get file icon
338+
* Get file icon.
342339
*
343340
* @param string $file
341+
*
344342
* @return string
345343
*/
346344
public function getFileIcon($file = '')

0 commit comments

Comments
 (0)