문제

In laravel I create model named 'Test':

class Test extends Eloquent { protected $table = 'test'; }

then run composer dump-autoload then I use this code in controller :

$arr = Test::first(); dd($arr);

but this error appear:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Test::first()

도움이 되었습니까?

해결책

You are probably not using that same Test class (extended from Eloquent), to be sure, you can get the full path of it by doing:

$reflector = new ReflectionClass('Test');

dd($reflector->getFileName());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top