2014-02-08 45 views
0

我试图使用Ardent的validate()方法验证用户,但我总是收到HY093错误并附带以下额外信息Laravel/Ardent:SQLSTATE [HY093]:无效的参数编号:混合的名称和位置参数

(SQL: select count(*) as aggregate from:用户where电子邮件= [email protected])

我用Sentry2为我的 '用户' 表数据库迁移。

我有我的用户模型建立这样的:

/** 
* Validation Rules for ARDENT here 
*/  
public static $rules = [ 
    'first_name'   => 'required', 
    'last_name'    => 'required', 
    'email'     => 'required|email|unique::users', 
    'password'    => 'required|between:8,32|confirmed', 
    'password_confirmation' => 'required|between:8,32', 
]; 

/** 
* The attributes that can be added to a new User using $user->fill() 
* 
* @var array 
*/ 
protected $fillable = [ 
    'first_name', 
    'last_name', 
    'email', 
    'password', 
    'password_confirmation' 
]; 

/** 
* Automatically removes _confirmation attributes 
* 
* @var boolean 
*/ 
public $autoPurgeRedundantAttributes = true; 

从一种形式,我有包括[ '邮件', 'FIRST_NAME', '姓氏', '密码' POST数据,“password_confirmation ]与去下面的函数在我UserController中各自的价值:

public function signup() { 
    // Create a new User object 
    $user = new User(); 

    // Populate attributes with information described in User->fillable 
    $user->fill(Input::all()); 

    // Check if info is valid using Ardent's validate() method 
    if ($user->validate()) { 
    .... 
    .... 
    .... 

我的代码总是失败的if ($user->validate())线。任何人都可以帮我解释一下这种情况吗?

回答

0

的问题是这条线

'email' => 'required|email|unique::users' 

本来应该

'email' => 'required|email|unique:users' 

根据The Laravel Docs

相关问题