Added the project's files to the repo
This commit is contained in:
57
app/Fieldprotocol/User/User.php
Executable file
57
app/Fieldprotocol/User/User.php
Executable file
@ -0,0 +1,57 @@
|
||||
<?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');
|
||||
}*/
|
||||
|
||||
}
|
Reference in New Issue
Block a user