英文:
Exception FatalThrowableError Class 'app\models\category' not found
问题
I can't understand where I made a mistake. The following is the error.
Symfony\Component\Debug\Exception\FatalThrowableError Class
'app\models\category' not found
<?php
class homepage extends Controller
{
public function index()
{
print_r(category::all());
die();
return view('frontend.homepage', $categories);
}
}
Error in line. print_r(category::all());die();
英文:
I can't understand where I made a mistake. The following is the error.
> Symfony\Component\Debug\Exception\FatalThrowableError Class
> 'app\models\category' not found
<!-- language: php -->
<?php
class homepage extends Controller
{
public function index()
{
print_r(category::all());
die();
return view('frontend.homepage', $categories);
}
}
Error in line. print_r(category::all());die();
答案1
得分: 0
将这一行代码从 use app\models\category;
更改为 use App\Models\Category;
。
public function index(){
print_r(Category::all());die();
$categories = Category::all();
return view('frontend.homepage',compact('categories'));
}
英文:
Change this line use app\models\category;
to this use App\Models\Category;
public function index(){
print_r(Category::all());die();
$categories = Category::all();
return view('frontend.homepage',compact('categories'));
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论