website/app/Fieldprotocol/User/User.php
2015-08-30 12:34:43 -04:00

58 lines
1.1 KiB
PHP
Executable File

<?php
namespace Fieldprotocol\User;
use Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent {
protected $table = 'users';
protected $fillable = [
'id',
'username',
'first_name',
'last_name',
'email',
'posts'
];
public function getFullName() {
if (!$this->first_name || !$this->last_name) {
return null;
}
return "{$this->first_name} {$this->last_name}";
}
public function getName() {
return $this->getFullName() ?: $this->username;
}
public function getAvatarUrl($options = []) {
$size = isset($options['size']) ? $options['size'] : 45;
return 'http://www.gravatar.com/avatar/' . md5($this->email) . '?s=' . $size . '&d=identicon';
}
/*public function permissions() {
return $this->hasOne('Fieldprotocol\User\UserPermission', 'user_id');
}
public function hasPermission($permission) {
return (bool) $this->permissions->{$permission};
}
public function isAdmin() {
return $this->hasPermission('is_admin');
}
public function isEditor() {
return $this->hasPermission('is_editor');
}
public function isAuthor() {
return $this->hasPermission('is_author');
}*/
}