Cachet/app/models/User.php
2015-01-01 18:57:33 +00:00

63 lines
1.3 KiB
PHP

<?php
use Illuminate\Auth\Reminders\RemindableInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
class User extends Model implements UserInterface, RemindableInterface
{
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The hidden properties.
*
* These are excluded when we are serializing the model.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* The properties that cannot be mass assigned.
*
* @var array
*/
protected $guarded = [];
/**
* Hash any password being inserted by default.
*
* @param string $password
*
* @return $this
*/
public function setPasswordAttribute($password)
{
$this->attributes['password'] = Hash::make($password);
return $this;
}
/**
* Returns a Gravatar URL for the users email address.
*
* @param int $size
*
* @return string
*/
public function getGravatarAttribute($size = 200)
{
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5($this->email), $size);
}
}