質問

I am doing a simple registration and login in laravel. I had previously built one taking laravel for a test drive prior to deciding to switch from CI. Anyway, the first time everything worked great. Upon reinstalling laravel, my User model does not seem to be loading. I can access User::method() for any properties or methods accessible in the Eloquent base model, but I cannot access any methods or properties declared static in my models/User.php model.

When I try and access a property I get "Access to undeclared static property"

I also tried to set a custom db table name for the users table and the system was not seeing this either. Not sure why it is loading, and not exactly sure how to check.

The User class is as follows:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {


public static $rules = array(
    'first_name'=>'required|alpha|min:2',
    'last_name'=>'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'
    );

    /* All other code in this is the standard code. */
 }

The route is as follows

Route::get('create', function(){
//include(app_path().'/models/User.php');
print_r(User::$rules);

});

If I leave the comments in I get "Access to undeclared static property: User::$rules"

If I take the comments out I get a the anticipated print.

役に立ちましたか?

解決

probably need to run php artisan dump-autoload from the command line

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top