找不到laravel模型类 [英] laravel model class not found
本文介绍了找不到laravel模型类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到找不到类模型的错误
I'm getting class model not found error
在我的模型课上
namespace App\models;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $table = 'customers';
}
在我的控制器中
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use \app\Models\Customer;
use Illuminate\Support\Facades\Input;
class RoomsController extends Controller
{
public function index()
{
$room= Customer::all();
return view('rooms',compact('room'));
}
}
我什至尝试了 composer dump-autoload
.我仍然遇到相同的错误
I even tried composer dump-autoload
.
I'm still getting the same error
推荐答案
在控制器头部使用use
Use use in head of your controller
use App\models\Customer;
比起您可以在函数中调用它而言
Than you can call it in your function:
Customer::find($id);//etc
这篇关于找不到laravel模型类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文