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

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

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

  1. <?php
  2. class homepage extends Controller
  3. {
  4. public function index()
  5. {
  6. print_r(category::all());
  7. die();
  8. return view('frontend.homepage', $categories);
  9. }
  10. }

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

  1. class homepage extends Controller
  2. {
  3. public function index()
  4. {
  5. print_r(category::all());
  6. die();
  7. return view(&#39;frontend.homepage&#39;, $categories);
  8. }
  9. }

Error in line. print_r(category::all());die();

答案1

得分: 0

将这一行代码从 use app\models\category; 更改为 use App\Models\Category;

  1. public function index(){
  2. print_r(Category::all());die();
  3. $categories = Category::all();
  4. return view('frontend.homepage',compact('categories'));
  5. }
英文:

Change this line use app\models\category; to this use App\Models\Category;

  1. public function index(){
  2. print_r(Category::all());die();
  3. $categories = Category::all();
  4. return view(&#39;frontend.homepage&#39;,compact(&#39;categories&#39;));
  5. }

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:

确定