Conditions | 7 |
Paths | 18 |
Total Lines | 36 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public static function makeColumnPhpCode() |
||
11 | { |
||
12 | $labels = request('column'); |
||
13 | $name = request('name'); |
||
14 | $isImage = request('is_image'); |
||
15 | $isDownload = request('is_download'); |
||
16 | $callback = request('callback'); |
||
17 | $width = request('width'); |
||
18 | |||
19 | $indent = str_repeat(' ', 8); |
||
20 | |||
21 | $columnScript = []; |
||
22 | $columnScript[] = $indent.'$this->col[] = [];'; |
||
23 | foreach ($labels as $i => $label) { |
||
24 | |||
25 | if (! $name[$i]) { |
||
26 | continue; |
||
27 | } |
||
28 | |||
29 | $colProperties = ["'label' => '$label'", "'name' => '{$name[$i]}'"]; |
||
30 | if ($isImage[$i]) { |
||
31 | $colProperties[] = '"image" => true '; |
||
32 | } |
||
33 | if ($isDownload[$i]) { |
||
34 | $colProperties[] = '"download" => true'; |
||
35 | } |
||
36 | if ($callback[$i]) { |
||
37 | $colProperties[] = '"callback" => function($row) {'.$callback[$i].'}'; |
||
38 | } |
||
39 | if ($width[$i]) { |
||
40 | $colProperties[] = "'width' => '$width[$i]'"; |
||
41 | } |
||
42 | |||
43 | $columnScript[] = $indent.'$this->col[] = ['.implode(", ", $colProperties).'];'; |
||
44 | } |
||
45 | return implode("\n", $columnScript); |
||
|
|||
46 | } |
||
48 | } |