@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function canPass() |
28 | 28 | { |
29 | 29 | $tot=0; |
30 | - foreach($this->problems->sortBy('order') as $problem){ |
|
30 | + foreach ($this->problems->sortBy('order') as $problem) { |
|
31 | 31 | $problem=$problem->problem; |
32 | 32 | $tot+=$problem->problem_status['color']=='wemd-green-text'; |
33 | 33 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | |
42 | 42 | public function getAvailabilityAttribute() |
43 | 43 | { |
44 | - foreach(explode(',', $this->precondition) as $dojo_id){ |
|
45 | - if(blank($dojo_id)) continue; |
|
46 | - if(!DojoPass::isPassed($dojo_id)) return 'locked'; |
|
44 | + foreach (explode(',', $this->precondition) as $dojo_id) { |
|
45 | + if (blank($dojo_id)) continue; |
|
46 | + if (!DojoPass::isPassed($dojo_id)) return 'locked'; |
|
47 | 47 | } |
48 | - return $this->passed?'passed':'available'; |
|
48 | + return $this->passed ? 'passed' : 'available'; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | } |
@@ -42,8 +42,12 @@ |
||
42 | 42 | public function getAvailabilityAttribute() |
43 | 43 | { |
44 | 44 | foreach(explode(',', $this->precondition) as $dojo_id){ |
45 | - if(blank($dojo_id)) continue; |
|
46 | - if(!DojoPass::isPassed($dojo_id)) return 'locked'; |
|
45 | + if(blank($dojo_id)) { |
|
46 | + continue; |
|
47 | + } |
|
48 | + if(!DojoPass::isPassed($dojo_id)) { |
|
49 | + return 'locked'; |
|
50 | + } |
|
47 | 51 | } |
48 | 52 | return $this->passed?'passed':'available'; |
49 | 53 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public static function isPassed($dojo_id) |
28 | 28 | { |
29 | - return Auth::check()?self::where([ |
|
29 | + return Auth::check() ?self::where([ |
|
30 | 30 | "dojo_id"=>$dojo_id, |
31 | 31 | "user_id"=>Auth::user()->id, |
32 | - ])->count()>0:false; |
|
32 | + ])->count()>0 : false; |
|
33 | 33 | } |
34 | 34 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public function members() |
12 | 12 | { |
13 | - return $this->hasMany('App\Models\Eloquent\GroupMember', 'gid','gid'); |
|
13 | + return $this->hasMany('App\Models\Eloquent\GroupMember', 'gid', 'gid'); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function banneds() |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | |
21 | 21 | public function getLeaderAttribute() |
22 | 22 | { |
23 | - return $this->members()->where('role',3)->first()->user; |
|
23 | + return $this->members()->where('role', 3)->first()->user; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getLinkAttribute() |
27 | 27 | { |
28 | - return route('group.detail',['gcode' => $this->gcode]); |
|
28 | + return route('group.detail', ['gcode' => $this->gcode]); |
|
29 | 29 | } |
30 | 30 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | use SoftDeletes; |
11 | 11 | |
12 | - protected $fillable = ['user_id', 'abuse_id', 'reason', 'removed_at']; |
|
12 | + protected $fillable=['user_id', 'abuse_id', 'reason', 'removed_at']; |
|
13 | 13 | |
14 | 14 | public function abuse() { |
15 | 15 | return $this->belongsTo('\App\Models\Eloquent\Abuse'); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | public function fetch() |
19 | 19 | { |
20 | - $list=DB::table($this->table)->orderBy('created_at','desc')->get()->all(); |
|
20 | + $list=DB::table($this->table)->orderBy('created_at', 'desc')->get()->all(); |
|
21 | 21 | if (empty($list)) { |
22 | 22 | return []; |
23 | 23 | } |
@@ -9,12 +9,12 @@ |
||
9 | 9 | { |
10 | 10 | public static function info($ltxsource, $type="png") |
11 | 11 | { |
12 | - if(!in_array($type,['png','svg'])) return []; |
|
12 | + if (!in_array($type, ['png', 'svg'])) return []; |
|
13 | 13 | $url=route("latex.$type", ['ltxsource' => $ltxsource]); |
14 | - $image = new Imagick(); |
|
14 | + $image=new Imagick(); |
|
15 | 15 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
16 | - $width = $image->getImageWidth(); |
|
17 | - $height = $image->getImageHeight(); |
|
18 | - return [$url,$width/5,$height/5]; |
|
16 | + $width=$image->getImageWidth(); |
|
17 | + $height=$image->getImageHeight(); |
|
18 | + return [$url, $width / 5, $height / 5]; |
|
19 | 19 | } |
20 | 20 | } |
@@ -9,7 +9,9 @@ |
||
9 | 9 | { |
10 | 10 | public static function info($ltxsource, $type="png") |
11 | 11 | { |
12 | - if(!in_array($type,['png','svg'])) return []; |
|
12 | + if(!in_array($type,['png','svg'])) { |
|
13 | + return []; |
|
14 | + } |
|
13 | 15 | $url=route("latex.$type", ['ltxsource' => $ltxsource]); |
14 | 16 | $image = new Imagick(); |
15 | 17 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @var string |
16 | 16 | */ |
17 | - protected $signature = 'babel:crawl |
|
17 | + protected $signature='babel:crawl |
|
18 | 18 | {extension : The package name of the extension} |
19 | 19 | {--action=crawl_problem : The action of the Crawler} |
20 | 20 | {--con=all : The target problemset of the Crawler} |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @var string |
28 | 28 | */ |
29 | - protected $description = 'Crawl problems for a given Babel Extension to NOJ'; |
|
29 | + protected $description='Crawl problems for a given Babel Extension to NOJ'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Create a new command instance. |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function handle() |
47 | 47 | { |
48 | - $extension = $this->argument('extension'); |
|
49 | - $action = $this->option('action'); |
|
50 | - $con = $this->option('con'); |
|
51 | - [$from, $to] = sscanf($this->option('range'),"%d:%d"); |
|
52 | - $cached = $this->option('cached'); |
|
48 | + $extension=$this->argument('extension'); |
|
49 | + $action=$this->option('action'); |
|
50 | + $con=$this->option('con'); |
|
51 | + [$from, $to]=sscanf($this->option('range'), "%d:%d"); |
|
52 | + $cached=$this->option('cached'); |
|
53 | 53 | $babel=new Babel(); |
54 | 54 | $babel->crawl([ |
55 | 55 | "name" => $extension, |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @var string |
15 | 15 | */ |
16 | - protected $signature = 'babel'; |
|
16 | + protected $signature='babel'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * The console command description. |
20 | 20 | * |
21 | 21 | * @var string |
22 | 22 | */ |
23 | - protected $description = 'List all babel commands'; |
|
23 | + protected $description='List all babel commands'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string |
27 | 27 | */ |
28 | - public static $logo = <<<LOGO |
|
28 | + public static $logo=<<<LOGO |
|
29 | 29 | |
30 | 30 | ███╗ ██╗ ██████╗ ██╗ ██████╗ █████╗ ██████╗ ███████╗██╗ |
31 | 31 | ████╗ ██║██╔═══██╗ ██║ ██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function handle() |
43 | 43 | { |
44 | 44 | $this->line(static::$logo); |
45 | - $this->line(sprintf('NOJ <comment>version</comment> <info>%s</info>',version())); |
|
45 | + $this->line(sprintf('NOJ <comment>version</comment> <info>%s</info>', version())); |
|
46 | 46 | |
47 | 47 | $this->comment(''); |
48 | 48 | $this->comment('Available commands:'); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | protected function listBabelCommands() |
59 | 59 | { |
60 | - $commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) { |
|
60 | + $commands=collect(Artisan::all())->mapWithKeys(function($command, $key) { |
|
61 | 61 | if (Str::startsWith($key, 'babel:')) { |
62 | 62 | return [$key => $command]; |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return []; |
66 | 66 | })->toArray(); |
67 | 67 | |
68 | - $width = $this->getColumnWidth($commands); |
|
68 | + $width=$this->getColumnWidth($commands); |
|
69 | 69 | |
70 | 70 | /** @var Command $command */ |
71 | 71 | foreach ($commands as $command) { |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function getColumnWidth(array $commands) |
82 | 82 | { |
83 | - $widths = []; |
|
83 | + $widths=[]; |
|
84 | 84 | |
85 | 85 | foreach ($commands as $command) { |
86 | - $widths[] = static::strlen($command->getName()); |
|
86 | + $widths[]=static::strlen($command->getName()); |
|
87 | 87 | foreach ($command->getAliases() as $alias) { |
88 | - $widths[] = static::strlen($alias); |
|
88 | + $widths[]=static::strlen($alias); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - return $widths ? max($widths) + 2 : 0; |
|
92 | + return $widths ? max($widths)+2 : 0; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function strlen($string) |
103 | 103 | { |
104 | - if (false === $encoding = mb_detect_encoding($string, null, true)) { |
|
104 | + if (false===$encoding=mb_detect_encoding($string, null, true)) { |
|
105 | 105 | return strlen($string); |
106 | 106 | } |
107 | 107 |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @var string |
15 | 15 | */ |
16 | - protected $signature = 'manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}'; |
|
16 | + protected $signature='manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * The console command description. |
20 | 20 | * |
21 | 21 | * @var string |
22 | 22 | */ |
23 | - protected $description = 'Ban a user'; |
|
23 | + protected $description='Ban a user'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Create a new command instance. |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function handle() |
41 | 41 | { |
42 | - $uid=(int)$this->option('uid'); |
|
42 | + $uid=(int) $this->option('uid'); |
|
43 | 43 | $reason=$this->option('reason'); |
44 | 44 | $time=$this->option('time'); |
45 | - $user = User::find($uid); |
|
46 | - if(empty($user)) { |
|
45 | + $user=User::find($uid); |
|
46 | + if (empty($user)) { |
|
47 | 47 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>User Not Found</>\n"); |
48 | 48 | return; |
49 | 49 | } |
50 | - try{ |
|
51 | - $ban_time = date('Y-m-d H:i:s',strtotime($time)); |
|
50 | + try { |
|
51 | + $ban_time=date('Y-m-d H:i:s', strtotime($time)); |
|
52 | 52 | UserBanned::create([ |
53 | 53 | 'user_id' => $user->id, |
54 | 54 | 'reason' => $reason, |
55 | 55 | 'removed_at' => $ban_time |
56 | 56 | ]); |
57 | 57 | $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>"); |
58 | - }catch(Throwable $e){ |
|
58 | + } catch (Throwable $e) { |
|
59 | 59 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n"); |
60 | 60 | return; |
61 | 61 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | 'removed_at' => $ban_time |
56 | 56 | ]); |
57 | 57 | $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>"); |
58 | - }catch(Throwable $e){ |
|
58 | + } catch(Throwable $e){ |
|
59 | 59 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n"); |
60 | 60 | return; |
61 | 61 | } |