Passed
Pull Request — master (#610)
by John
10:48
created
app/Admin/Controllers/ProblemController.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @return Form
145 145
      */
146
-    protected function form($create = false)
146
+    protected function form($create=false)
147 147
     {
148 148
         $form=new Form(new EloquentProblemModel);
149 149
         $form->model()->makeVisible('password');
150
-        $form->tab('Basic', function(Form $form){
150
+        $form->tab('Basic', function(Form $form) {
151 151
             $form->text('pid')->readonly();
152 152
             $form->text('pcode')->rules('required');
153 153
             $form->text('title')->rules('required');
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $form->simplemde('input');
158 158
             $form->simplemde('output');
159 159
             $form->simplemde('note');
160
-            $form->hasMany('problemSamples', 'samples', function (Form\NestedForm $form) {
160
+            $form->hasMany('problemSamples', 'samples', function(Form\NestedForm $form) {
161 161
                 $form->textarea('sample_input', 'sample input')->rows(3);
162 162
                 $form->textarea('sample_output', 'sample output')->rows(3);
163 163
                 $form->textarea('sample_note', 'sample note')->rows(3);
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
                 $table->textarea('sample_output', 'sample output');
168 168
                 $table->textarea('sample_note', 'sample note');
169 169
             }); */
170
-            $ojs_temp = EloquentOJModel::select('oid', 'name')->get()->all();
171
-            $ojs = [];
172
-            foreach($ojs_temp as $v){
173
-                $ojs[$v->oid] = $v->name;
170
+            $ojs_temp=EloquentOJModel::select('oid', 'name')->get()->all();
171
+            $ojs=[];
172
+            foreach ($ojs_temp as $v) {
173
+                $ojs[$v->oid]=$v->name;
174 174
             }
175 175
             $form->select('oj', 'OJ')->options($ojs)->default(1)->rules('required');
176 176
             /* $form->display('update_date'); */
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                     0 => 'NO',
190 190
                     1 => 'YES',
191 191
                 ])->default(0)->rules('required');
192
-            $form->clang('spj_src','SPJ Source Code');
192
+            $form->clang('spj_src', 'SPJ Source Code');
193 193
             $form->file('test_case')->rules('required');
194 194
             $form->ignore(['test_case']);
195 195
 
@@ -211,128 +211,128 @@  discard block
 block discarded – undo
211 211
                 $tools->append('<a href="/'.config('admin.route.prefix').'/problems/import" class="btn btn-sm btn-success" style="margin-right:1rem"><i class="MDI file-powerpoint-box"></i>&nbsp;&nbsp;Import from file</a>');
212 212
             });
213 213
         } */
214
-        $form->saving(function (Form $form){
215
-            $err = function ($msg, $title = 'Test case file parse faild.') {
216
-                $error = new MessageBag([
214
+        $form->saving(function(Form $form) {
215
+            $err=function($msg, $title='Test case file parse faild.') {
216
+                $error=new MessageBag([
217 217
                     'title'   => $title,
218 218
                     'message' => $msg,
219 219
                 ]);
220 220
                 return back()->with(compact('error'));
221 221
             };
222
-            $pcode = $form->pcode;
223
-            $p = EloquentProblemModel::where('pcode',$pcode)->first();
222
+            $pcode=$form->pcode;
223
+            $p=EloquentProblemModel::where('pcode', $pcode)->first();
224 224
             //check pcode has been token.
225
-            $pid = $form->pid ?? null;
226
-            if(!empty($p) && $p->pid != $pid){
225
+            $pid=$form->pid ?? null;
226
+            if (!empty($p) && $p->pid!=$pid) {
227 227
                 $err('Pcode has been token', 'Error occur.');
228 228
             }
229
-            $test_case = \request()->file('test_case');
229
+            $test_case=\request()->file('test_case');
230 230
             //Make sure the user enters SPJ_SRc in spj problem.
231
-            if($form->spj && empty($form->spj_src)) {
231
+            if ($form->spj && empty($form->spj_src)) {
232 232
                 $err('The SPJ problem must provide spj_src', 'create problem error');
233 233
             }
234 234
             //check info file. Try to generate if it does not exist.
235
-            $info_content = [];
236
-            if(!empty($test_case)){
237
-                if($test_case->extension() != 'zip'){
235
+            $info_content=[];
236
+            if (!empty($test_case)) {
237
+                if ($test_case->extension()!='zip') {
238 238
                     $err('You must upload a zip file iuclude test case info and content.');
239 239
                 }
240
-                $path = $test_case->path();
241
-                $zip = new ZipArchive;
242
-                if($zip->open($path) !== true) {
240
+                $path=$test_case->path();
241
+                $zip=new ZipArchive;
242
+                if ($zip->open($path)!==true) {
243 243
                     $err('You must upload a zip file without encrypt and can open successfully.');
244 244
                 };
245
-                $info_content = [];
246
-                if(($zip->getFromName('info')) === false){
247
-                    if(!$form->spj){
248
-                        $info_content = [
245
+                $info_content=[];
246
+                if (($zip->getFromName('info'))===false) {
247
+                    if (!$form->spj) {
248
+                        $info_content=[
249 249
                             'spj' => false,
250 250
                             'test_cases' => []
251 251
                         ];
252
-                        $files = [];
253
-                        for ($i = 0; $i < $zip->numFiles; $i++) {
254
-                            $filename = $zip->getNameIndex($i);
255
-                            $files[] = $filename;
252
+                        $files=[];
253
+                        for ($i=0; $i<$zip->numFiles; $i++) {
254
+                            $filename=$zip->getNameIndex($i);
255
+                            $files[]=$filename;
256 256
                         }
257
-                        $files_in = array_filter($files, function ($filename) {
258
-                            return strpos('.in', $filename) != -1;
257
+                        $files_in=array_filter($files, function($filename) {
258
+                            return strpos('.in', $filename)!=-1;
259 259
                         });
260 260
                         sort($files_in);
261
-                        $testcase_index = 1;
262
-                        if(!count($files_in)){
261
+                        $testcase_index=1;
262
+                        if (!count($files_in)) {
263 263
                             $err('Cannot detect any .in file, please make sure they are placed under the root directory of the zip file.');
264 264
                         }
265
-                        foreach($files_in as $filename_in){
266
-                            $filename = basename($filename_in, '.in');
267
-                            $filename_out = $filename.'.out';
268
-                            if(($zip->getFromName($filename_out)) === false) {
265
+                        foreach ($files_in as $filename_in) {
266
+                            $filename=basename($filename_in, '.in');
267
+                            $filename_out=$filename.'.out';
268
+                            if (($zip->getFromName($filename_out))===false) {
269 269
                                 continue;
270 270
                             }
271
-                            $test_case_in = preg_replace('~(*BSR_ANYCRLF)\R~',"\n", $zip->getFromName($filename_in));
272
-                            $test_case_out = preg_replace('~(*BSR_ANYCRLF)\R~',"\n", $zip->getFromName($filename_out));
273
-                            $info_content['test_cases']["{$testcase_index}"] = [
271
+                            $test_case_in=preg_replace('~(*BSR_ANYCRLF)\R~', "\n", $zip->getFromName($filename_in));
272
+                            $test_case_out=preg_replace('~(*BSR_ANYCRLF)\R~', "\n", $zip->getFromName($filename_out));
273
+                            $info_content['test_cases']["{$testcase_index}"]=[
274 274
                                 'input_size' => strlen($test_case_in),
275 275
                                 'input_name' => $filename_in,
276 276
                                 'output_size' => strlen($test_case_out),
277 277
                                 'output_name' => $filename_out,
278 278
                                 'stripped_output_md5' => md5(utf8_encode(rtrim($test_case_out)))
279 279
                             ];
280
-                            $testcase_index += 1;
280
+                            $testcase_index+=1;
281 281
                         }
282
-                    }else{
283
-                        $info_content = [
282
+                    } else {
283
+                        $info_content=[
284 284
                             'spj' => true,
285 285
                             'test_cases' => []
286 286
                         ];
287
-                        $files = [];
288
-                        for ($i = 0; $i < $zip->numFiles; $i++) {
289
-                            $filename = $zip->getNameIndex($i);
290
-                            $files[] = $filename;
287
+                        $files=[];
288
+                        for ($i=0; $i<$zip->numFiles; $i++) {
289
+                            $filename=$zip->getNameIndex($i);
290
+                            $files[]=$filename;
291 291
                         }
292
-                        $files_in = array_filter($files, function ($filename) {
293
-                            return strpos($filename, '.in') !== false;
292
+                        $files_in=array_filter($files, function($filename) {
293
+                            return strpos($filename, '.in')!==false;
294 294
                         });
295 295
                         sort($files_in);
296
-                        $testcase_index = 1;
297
-                        foreach($files_in as $filename_in){
298
-                            $test_case_in = $zip->getFromName($filename_in);
299
-                            $info_content['test_cases']["{$testcase_index}"] = [
296
+                        $testcase_index=1;
297
+                        foreach ($files_in as $filename_in) {
298
+                            $test_case_in=$zip->getFromName($filename_in);
299
+                            $info_content['test_cases']["{$testcase_index}"]=[
300 300
                                 'input_size' => strlen($test_case_in),
301 301
                                 'input_name' => $filename_in
302 302
                             ];
303
-                            $testcase_index += 1;
303
+                            $testcase_index+=1;
304 304
                         }
305 305
                     }
306 306
                     $zip->addFromString('info', json_encode($info_content));
307 307
                     $zip->close();
308 308
                     //$err('The zip files must include a file named info including info of test cases, and the format can see ZsgsDesign/NOJ wiki.');
309
-                }else{
310
-                    $info_content = json_decode($zip->getFromName('info'),true);
309
+                } else {
310
+                    $info_content=json_decode($zip->getFromName('info'), true);
311 311
                 };
312 312
                 $zip->open($path);
313 313
                 //If there is an INFO file, check that the contents of the file match the actual situation
314
-                $test_cases = $info_content['test_cases'];
314
+                $test_cases=$info_content['test_cases'];
315 315
                 //dd($test_cases);
316
-                foreach($test_cases as $index => $case) {
317
-                    if(!isset($case['input_name']) || (!$form->spj && !isset($case['output_name']))) {
316
+                foreach ($test_cases as $index => $case) {
317
+                    if (!isset($case['input_name']) || (!$form->spj && !isset($case['output_name']))) {
318 318
                         $err("Test case index {$index}: configuration missing input/output files name.");
319 319
                     }
320
-                    if($zip->getFromName($case['input_name']) === false || (!$form->spj && $zip->getFromName($case['output_name']) === false)) {
320
+                    if ($zip->getFromName($case['input_name'])===false || (!$form->spj && $zip->getFromName($case['output_name'])===false)) {
321 321
                         $err("Test case index {$index}: missing input/output files that record in the configuration.");
322 322
                     }
323 323
                 }
324
-                if(!empty($form->pid)){
325
-                    $problem = EloquentProblemModel::find($form->pid);
326
-                    if(!empty($problem)){
327
-                        $pcode = $problem->pcode;
328
-                    }else{
329
-                        $pcode = $form->pcode;
324
+                if (!empty($form->pid)) {
325
+                    $problem=EloquentProblemModel::find($form->pid);
326
+                    if (!empty($problem)) {
327
+                        $pcode=$problem->pcode;
328
+                    } else {
329
+                        $pcode=$form->pcode;
330 330
                     }
331
-                }else{
332
-                    $pcode = $form->pcode;
331
+                } else {
332
+                    $pcode=$form->pcode;
333 333
                 }
334 334
 
335
-                if(Storage::exists(base_path().'/storage/test_case/'.$pcode)){
335
+                if (Storage::exists(base_path().'/storage/test_case/'.$pcode)) {
336 336
                     Storage::deleteDirectory(base_path().'/storage/test_case/'.$pcode);
337 337
                 }
338 338
                 Storage::makeDirectory(base_path().'/storage/test_case/'.$pcode);
@@ -340,19 +340,19 @@  discard block
 block discarded – undo
340 340
 
341 341
             }
342 342
             //Set the spj-related data
343
-            if($form->spj){
344
-                $form->spj_lang = 'c';
345
-                $form->spj_version = "{$form->pcode}#".time();
343
+            if ($form->spj) {
344
+                $form->spj_lang='c';
345
+                $form->spj_version="{$form->pcode}#".time();
346 346
             }
347 347
             //Set default data
348
-            $form->tot_score = count($info_content['test_cases']);
349
-            $form->markdown = true;
350
-            $form->input_type = 'standard input';
351
-            $form->output_type = 'standard output';
352
-            $form->solved_count = 0;
353
-            $form->difficulty = -1;
354
-            $form->partial = 1;
355
-            $form->file = 0;
348
+            $form->tot_score=count($info_content['test_cases']);
349
+            $form->markdown=true;
350
+            $form->input_type='standard input';
351
+            $form->output_type='standard output';
352
+            $form->solved_count=0;
353
+            $form->difficulty=-1;
354
+            $form->partial=1;
355
+            $form->file=0;
356 356
         });
357 357
         return $form;
358 358
     }
Please login to merge, or discard this patch.
app/Admin/Controllers/DojoController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
         $grid=new Grid(new Dojo);
85 85
         $grid->column('id', "ID")->sortable();
86 86
         $grid->column("name", __('admin.dojos.name'))->editable();
87
-        $grid->column("dojo_phase", __('admin.dojos.phase'))->display(function () {
87
+        $grid->column("dojo_phase", __('admin.dojos.phase'))->display(function() {
88 88
             return $this->phase->name;
89 89
         });
90
-        $grid->column("totproblem", __('admin.dojos.totproblem'))->display(function () {
90
+        $grid->column("totproblem", __('admin.dojos.totproblem'))->display(function() {
91 91
             return $this->tot_problem;
92 92
         });
93 93
         $grid->column("passline", __('admin.dojos.passline'));
94
-        $grid->column("precondition", __('admin.dojos.precondition'))->display(function ($precondition) {
94
+        $grid->column("precondition", __('admin.dojos.precondition'))->display(function($precondition) {
95 95
             $output='';
96
-            foreach($precondition as $p){
96
+            foreach ($precondition as $p) {
97 97
                 $output.='<span class="label label-primary">'.Dojo::find($p)->name.'</span> ';
98 98
             }
99 99
             return $output;
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
         $grid->created_at(__('admin.created_at'));
103 103
         $grid->updated_at(__('admin.updated_at'));
104 104
 
105
-        $grid->filter(function (Grid\Filter $filter) {
106
-            $filter->column(6, function ($filter) {
105
+        $grid->filter(function(Grid\Filter $filter) {
106
+            $filter->column(6, function($filter) {
107 107
                 $filter->like('name', __('admin.dojos.name'));
108 108
             });
109
-            $filter->column(6, function ($filter) {
109
+            $filter->column(6, function($filter) {
110 110
                 $filter->equal('dojo_phase_id', __('admin.dojos.phase'))->select(DojoPhase::all()->pluck('name', 'cid'));
111 111
             });
112 112
         });
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     protected function form()
140 140
     {
141 141
         $form=new Form(new Dojo);
142
-        $form->tab('Basic', function (Form $form) {
142
+        $form->tab('Basic', function(Form $form) {
143 143
             $form->display('id', 'ID');
144 144
             $form->text('name', __('admin.dojos.name'))->rules('required');
145 145
             $form->textarea('description', __('admin.dojos.description'))->rules('required');
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $form->number('passline', __('admin.dojos.passline'))->default(0)->rules('required');
148 148
             $form->number('order', __('admin.dojos.order'))->default(0)->rules('required');
149 149
             $form->multipleSelect('precondition', __('admin.dojos.precondition'))->options(Dojo::all()->pluck('name', 'id'));
150
-            $form->hasMany('problems', __('admin.dojos.problems'), function (Form\NestedForm $form) {
150
+            $form->hasMany('problems', __('admin.dojos.problems'), function(Form\NestedForm $form) {
151 151
                 $form->select('problem_id', __('admin.dojos.problem'))->options(Problem::all()->pluck('readable_name', 'pid'))->required();
152 152
                 $form->number('order', __('admin.dojos.problemorder'))->default(0)->required();
153 153
             });
Please login to merge, or discard this patch.
app/Admin/Controllers/CodeTesterController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     protected function form()
39 39
     {
40 40
         $OJ=OJ::where(["ocode"=>"noj"])->get();
41
-        $box = new Box(__('admin.tester.tester.title'));
42
-        if(blank($OJ)) {
41
+        $box=new Box(__('admin.tester.tester.title'));
42
+        if (blank($OJ)) {
43 43
             $box->style('danger');
44 44
             $box->content(__('admin.tester.help.installfirst'));
45 45
             return $box;
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
             'solution' => request()->solution,
85 85
         ]);
86 86
         $verdict=$runner->verdict;
87
-        $boxRun = new Box(__('admin.tester.tester.run'));
87
+        $boxRun=new Box(__('admin.tester.tester.run'));
88 88
         $boxRun->style('info');
89 89
         $verdictData=[];
90
-        foreach($verdict['data'] as $v){
90
+        foreach ($verdict['data'] as $v) {
91 91
             $verdictData[]=[
92 92
                 $v["test_case"],
93 93
                 $v["cpu_time"],
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                 $v["result"],
100 100
             ];
101 101
         }
102
-        $table = new Table(['Test Case', 'CPU Time(ms)', 'Real Time(ms)', 'Memory(byte)', 'Signal', 'Exit Code', 'Error', 'Result'], $verdictData);
102
+        $table=new Table(['Test Case', 'CPU Time(ms)', 'Real Time(ms)', 'Memory(byte)', 'Signal', 'Exit Code', 'Error', 'Result'], $verdictData);
103 103
         $output="<p>Verdict: {$verdict['verdict']}</p>";
104 104
         if (!blank($verdict['compile_info'])) {
105 105
             $output.="<p>Compiler Info:</p><pre>".htmlspecialchars($verdict['compile_info'])."</pre>";
Please login to merge, or discard this patch.
app/Admin/Controllers/JudgerController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
      */
83 83
     protected function grid()
84 84
     {
85
-        $grid = new Grid(new Judger());
85
+        $grid=new Grid(new Judger());
86 86
 
87 87
         $grid->column('jid', 'JID');
88 88
         $grid->column('handle', __('admin.judgers.handle'))->editable();
89 89
         $grid->column('password', __('admin.judgers.password'))->editable();
90
-        $grid->column('available', __('admin.judgers.availability'))->display(function ($available) {
91
-            return $available?'<i class="MDI check-circle wemd-teal-text"></i> '.__('admin.judgers.available'):'<i class="MDI close-circle wemd-pink-text"></i> '.__('admin.judgers.unavailable');
90
+        $grid->column('available', __('admin.judgers.availability'))->display(function($available) {
91
+            return $available ? '<i class="MDI check-circle wemd-teal-text"></i> '.__('admin.judgers.available') : '<i class="MDI close-circle wemd-pink-text"></i> '.__('admin.judgers.unavailable');
92 92
         });
93
-        $grid->column('oid', __('admin.judgers.oj'))->display(function () {
93
+        $grid->column('oid', __('admin.judgers.oj'))->display(function() {
94 94
             return $this->oj->name;
95 95
         });
96 96
         $grid->column('user_id', __('admin.judgers.user_id'))->editable();
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      */
116 116
     protected function detail($id)
117 117
     {
118
-        $show = new Show(Judger::findOrFail($id));
118
+        $show=new Show(Judger::findOrFail($id));
119 119
 
120 120
         $show->field('jid', 'JID');
121 121
         $show->field('handle', __('admin.judgers.handle'));
122 122
         $show->field('password', __('admin.judgers.password'));
123
-        $show->field('available', __('admin.judgers.availability'))->as(function ($available) {
124
-            return $available?__('admin.judgers.available'):__('admin.judgers.unavailable');
123
+        $show->field('available', __('admin.judgers.availability'))->as(function($available) {
124
+            return $available ?__('admin.judgers.available') : __('admin.judgers.unavailable');
125 125
         });
126 126
         $show->field('oj.name', __('admin.judgers.oj'));
127 127
         $show->field('user_id', __('admin.judgers.user_id'));
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
      */
139 139
     protected function form()
140 140
     {
141
-        $form = new Form(new Judger());
141
+        $form=new Form(new Judger());
142 142
         $form->text('handle', __('admin.judgers.handle'))->help(__('admin.judgers.help.handle'))->required();
143 143
         $form->text('password', __('admin.judgers.password'))->help(__('admin.judgers.help.password'))->required();
144
-        $form->switch('available',__('admin.judgers.availability'))->default(true);
144
+        $form->switch('available', __('admin.judgers.availability'))->default(true);
145 145
         $form->select('oid', __('admin.judgers.oj'))->options(OJ::all()->pluck('name', 'oid'))->required();
146
-        $form->text('user_id',__('admin.judgers.user_id'))->help(__('admin.judgers.help.user_id'));
146
+        $form->text('user_id', __('admin.judgers.user_id'))->help(__('admin.judgers.help.user_id'));
147 147
         $form->hidden('using')->default(0);
148 148
         return $form;
149 149
     }
Please login to merge, or discard this patch.
app/Admin/Controllers/JudgeServerController.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     protected function grid()
84 84
     {
85
-        $grid = new Grid(new JudgeServer());
85
+        $grid=new Grid(new JudgeServer());
86 86
 
87 87
         $grid->column('jsid', 'JSID');
88 88
         $grid->column('scode', __('admin.judgeservers.scode'));
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
         $grid->column('host', __('admin.judgeservers.host'));
91 91
         $grid->column('port', __('admin.judgeservers.port'));
92 92
         $grid->column('token', __('admin.judgeservers.token'));
93
-        $grid->column('available', __('admin.judgeservers.availability'))->display(function ($available) {
94
-            return $available?__('admin.judgeservers.available'):__('admin.judgeservers.unavailable');
93
+        $grid->column('available', __('admin.judgeservers.availability'))->display(function($available) {
94
+            return $available ?__('admin.judgeservers.available') : __('admin.judgeservers.unavailable');
95 95
         });
96
-        $grid->column('OJ', __('admin.judgeservers.oj'))->display(function () {
96
+        $grid->column('OJ', __('admin.judgeservers.oj'))->display(function() {
97 97
             return $this->oj->name;
98 98
         });
99
-        $grid->column('usage', __('admin.judgeservers.usage'))->display(function ($usage) {
100
-            return blank($usage)?"-":"$usage%";
99
+        $grid->column('usage', __('admin.judgeservers.usage'))->display(function($usage) {
100
+            return blank($usage) ? "-" : "$usage%";
101 101
         });
102
-        $grid->column('status', __('admin.judgeservers.status'))->display(function ($status) {
103
-            $status = JudgerModel::$status[$status];
102
+        $grid->column('status', __('admin.judgeservers.status'))->display(function($status) {
103
+            $status=JudgerModel::$status[$status];
104 104
             return '<i class="MDI '.$status['icon'].' '.$status['color'].'"></i> '.$status['text'];
105 105
         });
106 106
         $grid->column('status_update_at', __('admin.judgeservers.status_update_at'));
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     protected function detail($id)
120 120
     {
121
-        $show = new Show(JudgeServer::findOrFail($id));
121
+        $show=new Show(JudgeServer::findOrFail($id));
122 122
 
123 123
         $show->field('jsid', 'JSID');
124 124
         $show->field('scode', __('admin.judgeservers.scode'));
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
         $show->field('host', __('admin.judgeservers.host'));
127 127
         $show->field('port', __('admin.judgeservers.port'));
128 128
         $show->field('token', __('admin.judgeservers.token'));
129
-        $show->field('available', __('admin.judgeservers.availability'))->as(function ($available) {
130
-            return $available?__('admin.judgeservers.available'):__('admin.judgeservers.unavailable');
129
+        $show->field('available', __('admin.judgeservers.availability'))->as(function($available) {
130
+            return $available ?__('admin.judgeservers.available') : __('admin.judgeservers.unavailable');
131 131
         });
132 132
         $show->field('oj.name', __('admin.judgeservers.oj'));
133
-        $show->field('usage', __('admin.judgeservers.usage'))->as(function ($usage) {
134
-            return blank($usage)?"-":"$usage%";
133
+        $show->field('usage', __('admin.judgeservers.usage'))->as(function($usage) {
134
+            return blank($usage) ? "-" : "$usage%";
135 135
         });
136
-        $show->field('status', __('admin.judgeservers.status'))->unescape()->as(function ($status) {
137
-            $status = JudgerModel::$status[$status];
136
+        $show->field('status', __('admin.judgeservers.status'))->unescape()->as(function($status) {
137
+            $status=JudgerModel::$status[$status];
138 138
             return '<i class="MDI '.$status['icon'].' '.$status['color'].'"></i> '.$status['text'];
139 139
         });
140 140
         $show->field('status_update_at', __('admin.judgeservers.status_update_at'));
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     protected function form()
153 153
     {
154
-        $form = new Form(new JudgeServer());
154
+        $form=new Form(new JudgeServer());
155 155
 
156 156
         $form->text('scode', __('admin.judgeservers.scode'))->required();
157 157
         $form->text('name', __('admin.judgeservers.name'))->required();
Please login to merge, or discard this patch.
app/Admin/Controllers/SubmissionController.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $grid=new Grid(new Submission);
88 88
         $grid->column('sid', "ID")->sortable();
89
-        $grid->column("time", __('admin.submissions.time'))->display(function ($time) {
89
+        $grid->column("time", __('admin.submissions.time'))->display(function($time) {
90 90
             return __('admin.submissions.timeFormat', ['time'=>$time]);
91 91
         });
92
-        $grid->column("memory", __('admin.submissions.memory'))->display(function ($memory) {
92
+        $grid->column("memory", __('admin.submissions.memory'))->display(function($memory) {
93 93
             return __('admin.submissions.memoryFormat', ['memory'=>$memory]);
94 94
         });
95
-        $grid->column('verdict', __('admin.submissions.verdict'))->display(function ($verdict) {
95
+        $grid->column('verdict', __('admin.submissions.verdict'))->display(function($verdict) {
96 96
             return '<i class="fa fa-circle '.$this->color.'"></i> '.$verdict;
97 97
         });
98 98
         $grid->column("language", __('admin.submissions.language'));
99
-        $grid->column("submission_date", __('admin.submissions.submission_date'))->display(function ($submission_date) {
99
+        $grid->column("submission_date", __('admin.submissions.submission_date'))->display(function($submission_date) {
100 100
             return date("Y-m-d H:i:s", $submission_date);
101 101
         });
102
-        $grid->column("user_name", __('admin.submissions.user_name'))->display(function () {
102
+        $grid->column("user_name", __('admin.submissions.user_name'))->display(function() {
103 103
             return $this->user->name;
104 104
         });
105
-        $grid->column("contest_name", __('admin.submissions.contest_name'))->display(function () {
106
-            if(!is_null($this->contest)) return $this->contest->name;
105
+        $grid->column("contest_name", __('admin.submissions.contest_name'))->display(function() {
106
+            if (!is_null($this->contest)) return $this->contest->name;
107 107
         });
108
-        $grid->column("readable_name", __('admin.submissions.readable_name'))->display(function () {
108
+        $grid->column("readable_name", __('admin.submissions.readable_name'))->display(function() {
109 109
             return $this->problem->readable_name;
110 110
         });
111
-        $grid->column("judger_name", __('admin.submissions.judger_name'))->display(function () {
111
+        $grid->column("judger_name", __('admin.submissions.judger_name'))->display(function() {
112 112
             return $this->judger_name;
113 113
         });
114 114
         $grid->column("share", __('admin.submissions.share'))->editable('select', [
115 115
             0 => __('admin.submissions.disableshare'),
116 116
             1 => __('admin.submissions.enableshare')
117 117
         ]);
118
-        $grid->column("parsed_score", __('admin.submissions.parsed_score'))->display(function () {
118
+        $grid->column("parsed_score", __('admin.submissions.parsed_score'))->display(function() {
119 119
             return $this->parsed_score;
120 120
         });
121
-        $grid->filter(function (Grid\Filter $filter) {
122
-            $filter->column(6, function ($filter) {
121
+        $grid->filter(function(Grid\Filter $filter) {
122
+            $filter->column(6, function($filter) {
123 123
                 $filter->like('verdict', __('admin.submissions.verdict'));
124 124
             });
125
-            $filter->column(6, function ($filter) {
125
+            $filter->column(6, function($filter) {
126 126
                 $filter->equal('cid', __('admin.submissions.cid'))->select(Contest::all()->pluck('name', 'cid'));
127 127
                 $filter->equal('uid', __('admin.submissions.uid'))->select(User::all()->pluck('name', 'id'));
128 128
                 $filter->equal('pid', __('admin.submissions.pid'))->select(Problem::all()->pluck('readable_name', 'pid'));
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
         $show->coid(__('admin.submissions.coid'));
163 163
         $show->vcid(__('admin.submissions.vcid'));
164 164
         $show->score(__('admin.submissions.parsed_score'));
165
-        $show->share(__('admin.submissions.share'))->using([__('admin.submissions.disableshare'),__('admin.submissions.enableshare')]);
165
+        $show->share(__('admin.submissions.share'))->using([__('admin.submissions.disableshare'), __('admin.submissions.enableshare')]);
166 166
         return $show;
167 167
     }
168 168
 
169 169
     private function codify($field, $lang=null)
170 170
     {
171
-        $field->unescape()->as(function ($value) use ($field,$lang) {
172
-            $field->border = false;
171
+        $field->unescape()->as(function($value) use ($field, $lang) {
172
+            $field->border=false;
173 173
             $hash=md5($value);
174 174
             if (blank($value)) {
175 175
                 $value=" ";
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     protected function form()
210 210
     {
211 211
         $form=new Form(new Submission);
212
-        $form->tab('Basic', function (Form $form) {
212
+        $form->tab('Basic', function(Form $form) {
213 213
             $form->display('sid', 'SID');
214 214
             $form->text('time', __('admin.submissions.time'))->rules('required');
215 215
             $form->text('memory', __('admin.submissions.memory'))->rules('required');
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,9 @@
 block discarded – undo
103 103
             return $this->user->name;
104 104
         });
105 105
         $grid->column("contest_name", __('admin.submissions.contest_name'))->display(function () {
106
-            if(!is_null($this->contest)) return $this->contest->name;
106
+            if(!is_null($this->contest)) {
107
+                return $this->contest->name;
108
+            }
107 109
         });
108 110
         $grid->column("readable_name", __('admin.submissions.readable_name'))->display(function () {
109 111
             return $this->problem->readable_name;
Please login to merge, or discard this patch.
app/Admin/routes.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
     $router->resource('judger', JudgerController::class);
26 26
     $router->resource('abuses', AbuseController::class);
27 27
 
28
-    Route::match(['GET','POST'],'codetester', 'CodeTesterController@tester')->name('admin.codetester.tester');
29
-    Route::match(['GET','POST'],'settings', 'SettingsController@index')->name('admin.settings.index');
28
+    Route::match(['GET', 'POST'], 'codetester', 'CodeTesterController@tester')->name('admin.codetester.tester');
29
+    Route::match(['GET', 'POST'], 'settings', 'SettingsController@index')->name('admin.settings.index');
30 30
 
31
-    Route::group(['prefix' => 'babel'], function (Router $router) {
31
+    Route::group(['prefix' => 'babel'], function(Router $router) {
32 32
         $router->get('/', 'BabelController@index')->name('admin.babel.index');
33 33
         $router->get('installed', 'BabelController@installed')->name('admin.babel.installed');
34 34
         $router->get('marketspace', 'BabelController@marketspace')->name('admin.babel.marketspace');
Please login to merge, or discard this patch.
app/Http/Controllers/Tool/Ajax/ImageHostingController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $user=Auth::user();
23 23
 
24
-        if(!$user->hasPermission(26)){
24
+        if (!$user->hasPermission(26)) {
25 25
             return ResponseModel::err(2001);
26 26
         }
27 27
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp'];
36 36
         if ($isValid && in_array($extension, $allow_extension)) {
37 37
             $path=$request->file('image')->store('/static/img/upload', 'NOJPublic');
38
-            $id = ImageHosting::create([
38
+            $id=ImageHosting::create([
39 39
                 'user_id' => $user->id,
40 40
                 'relative_path' => "/$path"
41 41
             ])->id;
Please login to merge, or discard this patch.
app/Http/Controllers/Tool/ImageHostingController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
     public function detail($id)
33 33
     {
34 34
         $image=ImageHosting::find($id);
35
-        if(is_null($image)) {
35
+        if (is_null($image)) {
36 36
             return abort('404');
37 37
         }
38
-        if(Auth::user()->id!=$image->user_id){
38
+        if (Auth::user()->id!=$image->user_id) {
39 39
             return abort('403');
40 40
         }
41 41
         return view('tool.imagehosting.detail', [
Please login to merge, or discard this patch.