aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/User.php5
-rw-r--r--database/migrations/2016_09_05_230150_add_isadmin_to_users.php28
-rw-r--r--resources/views/user/top.blade.php9
3 files changed, 39 insertions, 3 deletions
diff --git a/app/User.php b/app/User.php
index dda14ca..f1ff869 100644
--- a/app/User.php
+++ b/app/User.php
@@ -26,7 +26,7 @@ class User extends Model implements Authenticatable {
protected $table = 'users';
public $timestamps = false;
- protected $fillable = ['email', 'name'];
+ protected $fillable = ['email', 'name', 'isadmin'];
const VOTE_WEIGHT_BASE = 5;
@@ -43,6 +43,9 @@ class User extends Model implements Authenticatable {
}
public function voteWeight() {
+ if ($this->isadmin)
+ return Verb::ACCEPTED_VOTE_COUNT;
+
if ($this->points <= 0)
return 0;
diff --git a/database/migrations/2016_09_05_230150_add_isadmin_to_users.php b/database/migrations/2016_09_05_230150_add_isadmin_to_users.php
new file mode 100644
index 0000000..e548420
--- /dev/null
+++ b/database/migrations/2016_09_05_230150_add_isadmin_to_users.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddIsadminToUsers extends Migration {
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up() {
+ Schema::table('users', function (Blueprint $table) {
+ $table->boolean('isadmin')->default(false);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down() {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('isadmin');
+ });
+ }
+}
diff --git a/resources/views/user/top.blade.php b/resources/views/user/top.blade.php
index 4bc71c6..4116fcf 100644
--- a/resources/views/user/top.blade.php
+++ b/resources/views/user/top.blade.php
@@ -1,7 +1,12 @@
<?php
use HebrewParseTrainer\User;
+
+$users = User::where('isadmin', false)
+ ->orderBy('points', 'desc')
+ ->take(3)
+ ->get();
?>
-@if(count(User::all()) > 0)
+@if(count($users) > 0)
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Top contributors</h3>
@@ -16,7 +21,7 @@ use HebrewParseTrainer\User;
</tr>
</thead>
<tbody>
- @foreach(User::orderBy('points', 'desc')->take(3)->get() as $user)
+ @foreach($users as $user)
<tr>
<td><img src="https://gravatar.com/avatar/{{ md5(strtolower(trim($user->email))) }}?s=40"/></td>
<td>{{{ $user->name }}}</td>