2014-01-24 39 views
0

我正在做一個簡單的註冊和登錄laravel。在決定從CI切換之前,我以前曾經爲測試驅動構建過一個laravel。無論如何,第一次一切都很好。重新安裝laravel後,我的用戶模型似乎沒有加載。我可以訪問User :: method()獲取在Eloquent基礎模型中可訪問的任何屬性或方法,但我無法訪問在我的models/User.php模型中聲明爲靜態的任何方法或屬性。laravel用戶模式不加載

當我嘗試訪問屬性,我得到「訪問未申報的靜態屬性」

我也試圖爲用戶表自定義數據庫表名和系統並沒有看到這兩種。不知道它爲什麼加載,並不完全確定如何檢查。

用戶等級如下表所示:

<?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. */ 
} 

的路線如下

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

}); 

如果我離開的評論中,我得到「訪問未申報的靜態屬性:用戶:: $規則「

如果我拿出評論,我會得到預期的印刷品。

+0

現在我知道什麼是奇怪的。如果我包含「include(app_path()。/ models/User.php');」在我的路線或控制器中,我現在可以訪問添加的靜態屬性。這應該已經加載爲用戶模型。 – dspencerr

+0

請向我們展示您的代碼,而不是看你如何做事情使得這是一個猜謎遊戲。 –

+0

對不起,只是把代碼放好。第一篇文章。謝謝您的幫助。 – dspencerr

回答

2

可能需要從命令行運行php artisan dump-autoload

+1

謝謝,我已經知道了這一點,但是,是的,這是問題。 – dspencerr