我想在laravel 5.2應用程序中創建一個下拉列表。我想在我的視圖頁面中加載類別項目。但是當我加載頁面時,它顯示以下錯誤。Laravel 5.2:類別類別未找到
FatalErrorException在routes.php文件第47行:類「分類」未找到
如果有誰知道出了什麼問題,懇求幫助我完成它。
這裏是我的類別型號:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Category extends Model{
protected $table="categories";
protected $fillable = ['name'];
}
這裏是路線:
<?php
Route::get('/', function() {
$categories=Category::all();
return view('index')->with ('categories',$categories);
});
這裏是如果它需要查看頁面:您還沒有命名空間
<html>
<head>
<title>Cascading Dropwon</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<div class="container">
<h3>Categories and Subcategories Ajax</h3>
<div class="col-lg-4">
{!! Form::open(array('url' => '','files'=>true)) !!}
{!! Form::token(); !!}
<div class="form-group">
<label for="">Categories</label>
<select class="form-control input-sm" name="">
@foreach($categories as $category){
<option value="{{$category->id}}">{{$category->name}}</option>
}
@endforeach
</select>
</div>
<div class="form-group">
<label for="">Sub Categories</label>
<select class="form-control input-sm" name="">
<option value=""></option>
</select>
</div>
{!!Form::close()!!}
</div>
</div>
</body>
</html>
您試過'composer dump-autoload'嗎? – Ymartin