Commit 21d75827 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added number of matches to users overview

parent 1d768fd2
...@@ -9,13 +9,16 @@ ...@@ -9,13 +9,16 @@
<th>#</th> <th>#</th>
<th>{_'Username'}</th> <th>{_'Username'}</th>
<th>{_'Role'}</th> <th>{_'Role'}</th>
<th>{_'Matches'}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr n:foreach="$users as $user" data-href="user/{$user->id}"> <tr n:foreach="$users as $user" data-href="user/{$user->id}">
{var $h = new UserHelper($user)}
<td>{$user->id}</td> <td>{$user->id}</td>
<td>{$user->username}</td> <td>{$user->username}</td>
<td>{_$user->role}</td> <td>{_$user->role}</td>
<td>{$h->numberOfMatches()}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -112,10 +112,10 @@ class UserHelper { ...@@ -112,10 +112,10 @@ class UserHelper {
$this->user = $dbuser; $this->user = $dbuser;
} }
public function numberOfMatches($discipline) { public function numberOfMatches($discipline=null) {
return $this->user->related('match') $q = $this->user->related('match');
->where('discipline', $discipline) $discipline && $q->where('discipline', $discipline);
->count(); return $q->count();
} }
public function averageMatchScore($discipline) { public function averageMatchScore($discipline) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment