-1
出現消息「Class'app \ Models \ User'not found」,但我在幾個地方進行了研究,沒有任何解決方案奏效。類'app Models User'找不到Laravel 5.4
composer.json:
"autoload": {
"classmap": [
"database","Models"
],
"psr-4": {
"App\\": "app/"
}
},
user.php的:
namespace App\Models;
class User extends Eloquent{
public function allUsers(){
return self::all();
}
}
UserController.php:
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
class UserController extends Controller{
protected $user = null;
public function __construct(User $user){
$this->user = $user;
}
public function allUsers(){
return $this->user->allUsers();
}
public function getUser($id){
}
public function saveUser(){
}
public function updateUser($id){
}
public function deleteUser($id){
}
}
UserController的替代(不工作太)
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
class UserController extends Controller{
public function __construct(){
}
public function allUsers(){
$class = '\app\Models\User';
return $class::allUsers();
}
public function getUser($id){
}
public function saveUser(){
}
public function updateUser($id){
}
public function deleteUser($id){
}
}
有人可以幫助我嗎?