laravel model class not found

血红的双手。 提交于 2021-01-29 07:48:11

问题


I'm getting class model not found error

In my model class

namespace App\models;
use Illuminate\Database\Eloquent\Model;



 class Customer extends Model
{
protected $table = 'customers';  
}

And in my controller

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'));

}

}  

I even tried composer dump-autoload. I'm still getting the same error


回答1:


Use use in head of your controller

use App\models\Customer;

Than you can call it in your function:

Customer::find($id);//etc



回答2:


use App\Customer;

Use this in head of the controller



来源:https://stackoverflow.com/questions/42752552/laravel-model-class-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!