Cachet/app/models/User.php

63 lines
1.3 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;
2015-01-01 12:23:17 +00:00
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
2014-11-16 22:26:08 +00:00
2015-01-01 12:23:17 +00:00
class User extends Model implements UserInterface, RemindableInterface
2014-12-20 21:20:17 +00:00
{
use UserTrait, RemindableTrait;
2014-11-16 22:26:08 +00:00
/**
* The database table used by the model.
2014-12-30 18:19:22 +00:00
*
* @var string
*/
protected $table = 'users';
2014-11-16 22:26:08 +00:00
/**
2015-01-01 18:57:33 +00:00
* The hidden properties.
*
* These are excluded when we are serializing the model.
2014-12-30 18:19:22 +00:00
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
2015-01-01 18:57:33 +00:00
* The properties that cannot be mass assigned.
2014-12-30 18:19:22 +00:00
*
* @var array
*/
2014-12-04 23:40:28 +00:00
protected $guarded = [];
2014-12-01 16:46:56 +00:00
/**
2014-12-30 18:19:22 +00:00
* Hash any password being inserted by default.
2014-12-01 16:46:56 +00:00
*
2015-01-01 12:23:17 +00:00
* @param string $password
2014-12-30 18:19:22 +00:00
*
2015-01-01 18:57:33 +00:00
* @return $this
2014-12-01 16:46:56 +00:00
*/
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);
2015-01-01 18:57:33 +00:00
return $this;
2014-12-01 16:46:56 +00:00
}
2014-12-20 20:40:48 +00:00
/**
* Returns a Gravatar URL for the users email address.
2014-12-30 18:19:22 +00:00
*
* @param int $size
*
2014-12-20 20:40:48 +00:00
* @return string
*/
2014-12-20 21:20:17 +00:00
public function getGravatarAttribute($size = 200)
{
2015-01-01 12:23:17 +00:00
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5($this->email), $size);
2014-12-04 15:36:19 +00:00
}
}