我正在尝试验证一些数据。我在 scotch.io 找到了这个教程。我在我的 UsersController 中使用以下内容来尝试验证一些数据:
public function store(){
$validator = Validator::make(Input::all(), User::$rules);
return Redirect::action("UserController@index");
}
但是,我不断收到错误“访问未声明的静态属性:User::$rules”。难道我做错了什么?我试图使用'php artisan dump-autoload'
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
protected $fillable = array(
'username',
'forename',
'surname',
'email',
'telephone',
'password',
'admin',
'customer',
'verification_link'
);
public static $rules = array(
'name' => 'required', // just a normal required validation
'email' => 'required|email|unique:ducks', // required and must be unique in the ducks table
'password' => 'required',
'password_confirm' => 'required|same:password' // required and has to match the password field
);
}