سؤال

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