From fc5cef0efddbb1141b0a371108a23fc7f6e8d860 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 5 Sep 2016 22:30:47 +0200 Subject: Vote on verb suggestions --- app/User.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/User.php') diff --git a/app/User.php b/app/User.php index 3c1799d..dda14ca 100644 --- a/app/User.php +++ b/app/User.php @@ -28,6 +28,8 @@ class User extends Model implements Authenticatable { public $timestamps = false; protected $fillable = ['email', 'name']; + const VOTE_WEIGHT_BASE = 5; + public function changePoints($kind, $change, $verb = null) { $change = new PointChange; $change->user = $this->id; @@ -40,6 +42,13 @@ class User extends Model implements Authenticatable { $this->save(); } + public function voteWeight() { + if ($this->points <= 0) + return 0; + + return floor(log($this->points, self::VOTE_WEIGHT_BASE)); + } + public function setPasswordAttribute($pass) { $this->attributes['password'] = Hash::make($pass); } -- cgit v1.2.3