问题
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