Laravel用户注册问题


Laravel User Registration Issue

我正在尝试使用laravel4进行简单的用户注册form。我目前得到这个错误,当我提交form:

Symfony'Component'Debug'Exception'FatalErrorException thrown with message "Undefined class constant 'rules'"
Stacktrace:
#1 Symfony'Component'Debug'Exception'FatalErrorException in C:'wamp'www'growinlove.tld'app'controllers'UsersController.php:12
#0 Illuminate'Exception'Handler:handleShutdown in <#unknown>:0

这是我的Controller:

class UsersController extends BaseController {
    //Run when user visits site...Load a view
    public function index(){
        return View::make('home.index');
    }
    //Handles processing of registration form data
    public function postCreate(){
        $validator = Validator::make(Input::all(), User::rules);
        if($validator->passes()){
            //Save in DB - Success
            $user = new User;
            $user->fname = Input::get('fname'); //Get the details of form
            $user->lname = Input::get('lname');
            $user->email = Input::get('email');
            $password->password = Hash::make(Input::get('password'));//Encrypt the password
            $user->save();
            return Redirect::to('/books')->with('Thank you for Registering!');
        }else{
            //Display error - Failed
            return Redirect::to('/')->with('message', 'The Following Errors occurred')->withErrors($validator)->withInput();
        }
    }
}

我的View:

<!-- Register Form -->
    <form   action="{{ action('UsersController@postCreate') }}" method="post" role="form">
        <h2 class="form-signup-heading">Register</h2>
        <!-- Display Errors -->
        <ul>
            @foreach($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
        <!-- First Name -->
        <div class="form-group">
            <label>First Name</label>
            <input type="text" class="form-control" name="fname" /> 
        </div>
        <!-- Last Name -->
        <div class="form-group">
            <label>Last Name</label>
            <input type="text" class="form-control" name="lname" /> 
        </div>
        <!-- Email -->
        <div class="form-group">
            <label>Email</label>
            <input type="text" class="form-control" name="email" /> 
        </div>
        <!-- Password-->
        <div class="form-group">
            <label>Password</label>
            <input type="password" class="form-control" name="password" />  
        </div>
        <!-- Confirm Password -->
        <div class="form-group">
            <label>Confirm Password</label>
            <input type="password" class="form-control" name="password_confirmation" /> 
        </div>
        <input type="submit" value="Register" class="btn btn-primary"/>
    </form>

这是我的Model:

    public static $rules = array(
        'firstname'=>'required|alpha|min:2',
        'lastname'=>'required|alpha|min:2',
        'email'=>'required|email|unique:users',
        'password'=>'required|alpha_num|between:6,12|confirmed',
        'password_confirmation'=>'required|alpha_num|between:6,12'
    );
    use UserTrait, RemindableTrait;

问题在UserController的第12行。用User::$rules代替User::rules

替换控制器

$validator = Validator::make(Input::all(), User::rules);

$validator = Validator::make(Input::all(), User::$rules);