aboutsummaryrefslogtreecommitdiff
path: root/app/User.php
diff options
context:
space:
mode:
authorCamil Staps2016-09-05 22:30:47 +0200
committerCamil Staps2016-09-05 22:30:47 +0200
commitfc5cef0efddbb1141b0a371108a23fc7f6e8d860 (patch)
tree8b3e62b50e5f856c57af477a78a51567d6e859f2 /app/User.php
parentUser creation and authentication (diff)
Vote on verb suggestions
Diffstat (limited to 'app/User.php')
-rw-r--r--app/User.php9
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);
}