Attendize/app/Models/User.php

109 lines
2.2 KiB
PHP
Raw Normal View History

2016-03-05 00:18:10 +00:00
<?php
namespace App\Models;
2016-02-29 15:59:36 +00:00
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
2016-03-05 00:18:10 +00:00
use Illuminate\Database\Eloquent\Model;
2016-02-29 15:59:36 +00:00
use Illuminate\Database\Eloquent\SoftDeletes;
2016-03-05 00:18:10 +00:00
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
2016-02-29 15:59:36 +00:00
use Authenticatable, CanResetPassword, SoftDeletes;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
2016-03-09 22:05:39 +00:00
public $dates = ['deleted_at'];
2016-02-29 15:59:36 +00:00
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
2016-03-05 00:18:10 +00:00
protected $hidden = ['password'];
2016-02-29 15:59:36 +00:00
2016-03-09 22:05:39 +00:00
protected $fillable = [
'account_id',
'first_name',
'last_name',
'phone',
'email',
'password',
'confirmation_code',
'is_registered',
'is_confirmed',
'is_parent',
'remember_token'
];
2016-03-05 00:18:10 +00:00
public function account()
{
2016-02-29 15:59:36 +00:00
return $this->belongsTo('\App\Models\Account');
}
2016-03-05 00:18:10 +00:00
public function activity()
{
2016-02-29 15:59:36 +00:00
return $this->hasMany('\App\Models\Activity');
}
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
2016-03-05 00:18:10 +00:00
public function getAuthIdentifier()
{
2016-02-29 15:59:36 +00:00
return $this->getKey();
}
/**
* Get the password for the user.
*
* @return string
*/
2016-03-05 00:18:10 +00:00
public function getAuthPassword()
{
2016-02-29 15:59:36 +00:00
return $this->password;
}
/**
* Get the e-mail address where password reminders are sent.
*
* @return string
*/
2016-03-05 00:18:10 +00:00
public function getReminderEmail()
{
2016-02-29 15:59:36 +00:00
return $this->email;
}
2016-03-05 00:18:10 +00:00
public function getRememberToken()
{
2016-02-29 15:59:36 +00:00
return $this->remember_token;
}
2016-03-05 00:18:10 +00:00
public function setRememberToken($value)
{
2016-02-29 15:59:36 +00:00
$this->remember_token = $value;
}
2016-03-05 00:18:10 +00:00
public function getRememberTokenName()
{
2016-02-29 15:59:36 +00:00
return 'remember_token';
}
2016-03-05 00:18:10 +00:00
public static function boot()
{
2016-02-29 15:59:36 +00:00
parent::boot();
2016-03-05 00:18:10 +00:00
static::creating(function ($user) {
2016-02-29 15:59:36 +00:00
$user->confirmation_code = str_random();
});
}
}