@@ -98,7 +98,7 @@ |
||
| 98 | 98 | $tournament = Tournament::where('slug', $request->tournamentSlug)->first(); |
| 99 | 99 | // Parse Csv File |
| 100 | 100 | |
| 101 | - $reader = Excel::load("storage/app/" . $file, function ($reader) { |
|
| 101 | + $reader = Excel::load("storage/app/" . $file, function($reader) { |
|
| 102 | 102 | })->get(); |
| 103 | 103 | |
| 104 | 104 | // Checking if malformed email |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public static function sendInvites($reader, $tournament) |
| 39 | 39 | { |
| 40 | - $reader->each(function ($sheet) use ($tournament) { |
|
| 40 | + $reader->each(function($sheet) use ($tournament) { |
|
| 41 | 41 | // Loop through all rows of spreadsheet |
| 42 | - $sheet->each(function ($row) use ($tournament) { |
|
| 42 | + $sheet->each(function($row) use ($tournament) { |
|
| 43 | 43 | // Check email |
| 44 | 44 | $invite = new Invite(); |
| 45 | 45 | $code = $invite->generateTournamentInvite($row, $tournament); |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function checkBadEmailsInExcel($reader, $tournament) |
| 120 | 120 | { |
| 121 | - $reader->each(function ($sheet) use ($tournament) { |
|
| 121 | + $reader->each(function($sheet) use ($tournament) { |
|
| 122 | 122 | // Loop through all rows |
| 123 | - $sheet->each(function ($row) use ($tournament) { |
|
| 123 | + $sheet->each(function($row) use ($tournament) { |
|
| 124 | 124 | // Check email |
| 125 | 125 | if (!filter_var($row, FILTER_VALIDATE_EMAIL)) { |
| 126 | 126 | $this->emailBadFormat = true; |
@@ -67,8 +67,9 @@ |
||
| 67 | 67 | $invite->expiration = $tournament->registerDateLimit; |
| 68 | 68 | $invite->active = true; |
| 69 | 69 | |
| 70 | - if ($invite->save()) |
|
| 71 | - return $token; |
|
| 70 | + if ($invite->save()) { |
|
| 71 | + return $token; |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | return null; |
| 74 | 75 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public static function boot() |
| 70 | 70 | { |
| 71 | 71 | parent::boot(); |
| 72 | - static::creating(function ($user) { |
|
| 72 | + static::creating(function($user) { |
|
| 73 | 73 | $softDeletedUser = User::onlyTrashed()->where('email', '=', $user->email)->first(); |
| 74 | 74 | if ($softDeletedUser != null) { |
| 75 | 75 | $softDeletedUser->restore(); |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | // If a User is deleted, you must delete: |
| 86 | 86 | // His tournaments, his competitors |
| 87 | 87 | |
| 88 | - static::deleting(function ($user) { |
|
| 88 | + static::deleting(function($user) { |
|
| 89 | 89 | $user->tournaments->each->delete(); |
| 90 | 90 | $user->competitors->each->delete(); |
| 91 | 91 | |
| 92 | 92 | }); |
| 93 | - static::restoring(function ($user) { |
|
| 93 | + static::restoring(function($user) { |
|
| 94 | 94 | $user->competitors()->withTrashed()->get()->each->restore(); |
| 95 | 95 | $user->tournaments()->withTrashed()->get()->each->restore(); |
| 96 | 96 | }); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | protected static function boot() |
| 52 | 52 | { |
| 53 | 53 | parent::boot(); |
| 54 | - static::deleting(function ($tournament) { |
|
| 54 | + static::deleting(function($tournament) { |
|
| 55 | 55 | $tournament->championships->each->delete(); |
| 56 | 56 | $tournament->invites->each->delete(); |
| 57 | 57 | |
| 58 | 58 | }); |
| 59 | - static::restoring(function ($tournament) { |
|
| 59 | + static::restoring(function($tournament) { |
|
| 60 | 60 | $tournament->championships()->withTrashed()->get()->each->restore(); |
| 61 | 61 | }); |
| 62 | 62 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | public function buildCategoryList() |
| 362 | 362 | { |
| 363 | 363 | $championships = Championship::with('category', 'settings') |
| 364 | - ->whereHas('category', function ($query) { |
|
| 364 | + ->whereHas('category', function($query) { |
|
| 365 | 365 | return $query->where('isTeam', 1); |
| 366 | 366 | }) |
| 367 | 367 | ->where('tournament_id', $this->id) |
@@ -300,7 +300,10 @@ |
||
| 300 | 300 | */ |
| 301 | 301 | public function setAndConfigureCategories($ruleId) |
| 302 | 302 | { |
| 303 | - if ($ruleId == 0) return; // No Rules Selected |
|
| 303 | + if ($ruleId == 0) { |
|
| 304 | + return; |
|
| 305 | + } |
|
| 306 | + // No Rules Selected |
|
| 304 | 307 | |
| 305 | 308 | $options = $this->loadRulesOptions($ruleId); |
| 306 | 309 | |
@@ -65,10 +65,11 @@ |
||
| 65 | 65 | $user->slug = str_slug($userData->name); |
| 66 | 66 | $user->email = $userData->email; |
| 67 | 67 | $user->firstname = $userData->name; |
| 68 | - if (strlen($userData->nickname) != 0) |
|
| 69 | - $user->name = $userData->nickname; |
|
| 70 | - else |
|
| 71 | - $user->name = $userData->email; |
|
| 68 | + if (strlen($userData->nickname) != 0) { |
|
| 69 | + $user->name = $userData->nickname; |
|
| 70 | + } else { |
|
| 71 | + $user->name = $userData->email; |
|
| 72 | + } |
|
| 72 | 73 | $user->save(); |
| 73 | 74 | } |
| 74 | 75 | } |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | return $query->where('federation_id', $user->federationOwned->id); |
| 115 | 115 | case |
| 116 | 116 | $user->isAssociationPresident() && $user->associationOwned: |
| 117 | - return $query->whereHas('association', function ($query) use ($user) { |
|
| 117 | + return $query->whereHas('association', function($query) use ($user) { |
|
| 118 | 118 | $query->where('id', $user->associationOwned->id); |
| 119 | 119 | }); |
| 120 | 120 | case $user->isClubPresident() && $user->clubOwned: |
@@ -82,10 +82,12 @@ |
||
| 82 | 82 | */ |
| 83 | 83 | public function federation() |
| 84 | 84 | { |
| 85 | - if ($this->association != null) |
|
| 86 | - return $this->association->federation(); |
|
| 87 | - else |
|
| 88 | - return $this->association(); //TODO THIS IS BAD :( |
|
| 85 | + if ($this->association != null) { |
|
| 86 | + return $this->association->federation(); |
|
| 87 | + } else { |
|
| 88 | + return $this->association(); |
|
| 89 | + } |
|
| 90 | + //TODO THIS IS BAD :( |
|
| 89 | 91 | } |
| 90 | 92 | |
| 91 | 93 | /** |
@@ -86,9 +86,14 @@ |
||
| 86 | 86 | private function rmdir_recursive($dir) |
| 87 | 87 | { |
| 88 | 88 | foreach (scandir($dir) as $file) { |
| 89 | - if ('.' === $file || '..' === $file) continue; |
|
| 90 | - if (is_dir("$dir/$file")) $this->rmdir_recursive("$dir/$file"); |
|
| 91 | - else unlink("$dir/$file"); |
|
| 89 | + if ('.' === $file || '..' === $file) { |
|
| 90 | + continue; |
|
| 91 | + } |
|
| 92 | + if (is_dir("$dir/$file")) { |
|
| 93 | + $this->rmdir_recursive("$dir/$file"); |
|
| 94 | + } else { |
|
| 95 | + unlink("$dir/$file"); |
|
| 96 | + } |
|
| 92 | 97 | } |
| 93 | 98 | rmdir($dir); |
| 94 | 99 | } |
@@ -46,16 +46,18 @@ |
||
| 46 | 46 | |
| 47 | 47 | public function edit(User $user, Federation $federation) |
| 48 | 48 | { |
| 49 | - if ($user->federationOwned == null) |
|
| 50 | - return false; |
|
| 49 | + if ($user->federationOwned == null) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | return $user->federationOwned->id == $federation->id; |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | public function update(User $user, Federation $federation) |
| 56 | 57 | { |
| 57 | - if ($user->federationOwned == null) |
|
| 58 | - return false; |
|
| 58 | + if ($user->federationOwned == null) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | return $user->federationOwned->id == $federation->id; |
| 61 | 63 | } |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function index(Tournament $tournament) |
| 28 | 28 | { |
| 29 | - $tournament = Tournament::with(['championships' => function ($query) { |
|
| 29 | + $tournament = Tournament::with(['championships' => function($query) { |
|
| 30 | 30 | $query->with('teams') |
| 31 | - ->whereHas('category', function ($subquery) { |
|
| 31 | + ->whereHas('category', function($subquery) { |
|
| 32 | 32 | $subquery->where('isTeam', '=', 1); |
| 33 | 33 | }); |
| 34 | 34 | }])->withCount('competitors', 'teams') |
| 35 | 35 | ->find($tournament->id); |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - $arrChampionshipsWithTeamsAndCompetitors = $tournament->championships->map(function ($championship) { |
|
| 39 | - $competitors = $championship->competitors->load('user')->map(function ($competitor) { |
|
| 38 | + $arrChampionshipsWithTeamsAndCompetitors = $tournament->championships->map(function($championship) { |
|
| 39 | + $competitors = $championship->competitors->load('user')->map(function($competitor) { |
|
| 40 | 40 | return ["id" => $competitor->id, "name" => $competitor->user->name]; |
| 41 | 41 | })->toArray(); |
| 42 | - $teams = $championship->teams()->with('competitors.user')->select('id','name')->get()->toArray(); |
|
| 42 | + $teams = $championship->teams()->with('competitors.user')->select('id', 'name')->get()->toArray(); |
|
| 43 | 43 | $tempAssignCompatitors = new Collection(); |
| 44 | 44 | $assignedCompetitors = $this->getAssignedCompetitors($championship, $tempAssignCompatitors); |
| 45 | 45 | $freeCompetitors = $championship->competitors; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private function getAssignedCompetitors($championship, $tempAssignCompatitors) |
| 68 | 68 | { |
| 69 | - return $championship->teams->reduce(function ($acc, $team) use ($tempAssignCompatitors) { |
|
| 69 | + return $championship->teams->reduce(function($acc, $team) use ($tempAssignCompatitors) { |
|
| 70 | 70 | return $tempAssignCompatitors->push($team->competitors()->with('user')->get())->collapse(); |
| 71 | 71 | }); |
| 72 | 72 | } |