Cachet/app/models/User.php

55 lines
1.2 KiB
PHP
Raw Normal View History

2014-11-16 22:26:08 +00:00
<?php
use Illuminate\Auth\Reminders\RemindableInterface;
2014-12-20 21:20:17 +00:00
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait;
2014-11-16 22:26:08 +00:00
2014-12-20 21:20:17 +00:00
class User extends Eloquent implements UserInterface, RemindableInterface
{
use UserTrait, RemindableTrait;
2014-11-16 22:26:08 +00:00
/**
* The database table used by the model.
* @var string
*/
protected $table = 'users';
2014-11-16 22:26:08 +00:00
/**
* The attributes excluded from the model's JSON form.
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
2014-12-04 23:40:28 +00:00
* Items which cannot be mass assigned.
* @var array
*/
2014-12-04 23:40:28 +00:00
protected $guarded = [];
2014-12-01 16:46:56 +00:00
/**
* Hash any password being inserted by default
*
* @param string @password
* @return void
*/
2014-12-20 21:20:17 +00:00
public function setPasswordAttribute($password)
{
2014-12-01 16:46:56 +00:00
$this->attributes['password'] = Hash::make($password);
}
2014-12-20 20:40:48 +00:00
/**
* Returns a Gravatar URL for the users email address.
* @param integer $size
* @return string
*/
2014-12-20 21:20:17 +00:00
public function getGravatarAttribute($size = 200)
{
2014-12-20 20:40:48 +00:00
return sprintf(
'https://www.gravatar.com/avatar/%s?size=%d',
md5($this->email),
$size
);
2014-12-04 15:36:19 +00:00
}
}