Cachet/app/models/User.php
2015-01-01 13:50:16 +00:00

59 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 attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* Items which cannot be mass assigned.
*
* @var array
*/
protected $guarded = [];
/**
* Hash any password being inserted by default.
*
* @param string $password
*
* @return void
*/
public function setPasswordAttribute($password)
{
$this->attributes['password'] = Hash::make($password);
}
/**
* 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);
}
}