Ali*_*aba 3 php laravel laravel-5
我正在构建我的第一个Laravel应用程序,我正在试图弄清楚我应该如何在模型级别上散列密码.
问题是,当尝试使用Laravel Hash::类时,无法找到它.我试图查找相关的API文档,但除了对Illuminate命名空间类的一些引用之外找不到任何东西- 从我收集的内容Hash::应该是全局可用的?
我是PHP命名空间的新手,我猜这可能与问题有关,因为错误表明它正在寻找App\Hash并且我知道它不是App命名空间的一部分,而是Illuminate一个.
这是我的代码:
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['first_name', 'last_name', 'default_currency', 'default_timezone', 'default_location', 'email', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
public function setPasswordAttribute($value) {
$this->attributes['password'] = Hash::make($value);
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助找出路线的原因,任何建议将不胜感激!