From 1ae38f7f50a31502909c91826488e6181ce07beb Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 6 Sep 2016 01:05:38 +0200 Subject: Added isadmin to users --- app/User.php | 5 +++- .../2016_09_05_230150_add_isadmin_to_users.php | 28 ++++++++++++++++++++++ resources/views/user/top.blade.php | 9 +++++-- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2016_09_05_230150_add_isadmin_to_users.php 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 @@ +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 @@ orderBy('points', 'desc') + ->take(3) + ->get(); ?> -@if(count(User::all()) > 0) +@if(count($users) > 0)