2013-07-25 23:33:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Entities;
|
|
|
|
|
2013-07-27 02:15:07 +02:00
|
|
|
use Cover;
|
|
|
|
use Gravatar;
|
2013-07-25 23:33:04 +02:00
|
|
|
use Illuminate\Auth\UserInterface;
|
|
|
|
use Illuminate\Auth\Reminders\RemindableInterface;
|
|
|
|
|
|
|
|
class User extends \Eloquent implements UserInterface, RemindableInterface {
|
|
|
|
protected $table = 'users';
|
|
|
|
protected $hidden = ['password_hash', 'password_salt', 'bio'];
|
|
|
|
|
2013-07-27 02:15:07 +02:00
|
|
|
public function avatar() {
|
|
|
|
return $this->hasOne('Entities\Image');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cover() {
|
|
|
|
return $this->belongsTo('Entities\Image');
|
|
|
|
}
|
|
|
|
|
2013-07-25 23:33:04 +02:00
|
|
|
public function getAuthIdentifier() {
|
|
|
|
return $this->getKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthPassword() {
|
|
|
|
return $this->password_hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getReminderEmail() {
|
|
|
|
return $this->email;
|
|
|
|
}
|
2013-07-27 02:15:07 +02:00
|
|
|
|
|
|
|
public function getAvatarUrl($type = Cover::NORMAL) {
|
|
|
|
if (!$this->uses_gravatar)
|
|
|
|
return $this->cover->getUrl();
|
|
|
|
|
|
|
|
$email = $this->gravatar;
|
|
|
|
if (!strlen($email))
|
|
|
|
$email = $this->email;
|
|
|
|
|
|
|
|
return Gravatar::getUrl($email, Image::$ImageTypes[$type]['width']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAvatarFile($type = Cover::NORMAL) {
|
|
|
|
if ($this->uses_gravatar)
|
|
|
|
return $this->user->getAvatar($type);
|
|
|
|
|
|
|
|
$cover = Cover::$Covers[$type];
|
|
|
|
return URL::to('t' . $this->id . '/cover_' . $cover['name'] . '.png?' . $this->cover_id);
|
|
|
|
}
|
2013-07-25 23:33:04 +02:00
|
|
|
}
|