diff options
author | Camil Staps | 2016-09-05 22:30:47 +0200 |
---|---|---|
committer | Camil Staps | 2016-09-05 22:30:47 +0200 |
commit | fc5cef0efddbb1141b0a371108a23fc7f6e8d860 (patch) | |
tree | 8b3e62b50e5f856c57af477a78a51567d6e859f2 /app/User.php | |
parent | User creation and authentication (diff) |
Vote on verb suggestions
Diffstat (limited to 'app/User.php')
-rw-r--r-- | app/User.php | 9 |
1 files changed, 9 insertions, 0 deletions
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); } |