2014-07-16 2 views
-1

컨트롤러 이름 : UserController.php모델 laravel 작동하지

public function getIndex() 
{ 
    $users = DB::table('users')->get(); //Working 
    $users = User::all(); //Not Working 
} 

모델명 : User.php는

class User extends Eloquent {} 

ORM의 문제는 웅변 무엇입니까? 내가 Laravel 4.2.6

+0

"작동하지 않음"이란 무엇을 의미합니까? 모든 예외, 오류 메시지? –

+0

"작동하지 않음"을 정의하십시오. 우리는 당신이 그 의미를 알지 못합니다. – lagbox

+0

Symfony \ Component \ Debug \ Exception \ FatalErrorException '사용자'클래스를 찾을 수 없습니다. –

답변

0

신선한 laravel 4.2 사용자 모델을 사용하고하는 것은 나는 그것이 작동하도록하기 위해 다음과 같이 좋아한다고 생각이

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'); 

} 

것 같습니다.

+1

필자는 이러한 특성과 인터페이스가 기본 'User :: all()'이 아닌 암호 미리 알림, 인증 등과 같은 사용자 별 작업에만 필요하다고 확신합니다. –

+0

사용자 모델은 다음과 같습니다. 그 당시에도 같은 문제가있었습니다. –

+0

Angish Tangbe : 질문에있는 주석에서 예외를 주면'composer dump-autoload' 명령을 시도 했습니까? – delmadord