1

i test laravel 5 that i have controller name Usercontroller.php have code:

 class UserController extends Controller { protected $user = null; public function __construct(User $user) { $this->user = $user; } public function allUsers() { return $this->user->allUsers(); } } 

and i create model name user.php have code:

class User extends Model { public function allUsers() { return self::all(); } } 

when i run it show error like below

ReflectionException in compiled.php line 1049: Class App\Http\Controllers\User does not exist 

please help me solve about this problem, thanks you.

1 Answer 1

2

The User model is found in the namespace App and you have to reference it like that:

public function __construct(\App\User $user) { $this->user = $user; } 

Or add an import statement at the top:

use App\User; class UserController extends Controller 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.