Exception FatalThrowableError Class 'app\models\category' not found

huangapple go评论67阅读模式
英文:

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(&#39;frontend.homepage&#39;, $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(&#39;frontend.homepage&#39;,compact(&#39;categories&#39;));

}

huangapple
  • 本文由 发表于 2020年1月3日 21:40:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579621.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定