收到问题“找不到类'App / Category'”

时间:2019-03-20 09:11:30

标签: laravel-5 laravel-5.2 laravel-5.1

在Category.php

namespace App;

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

和在Controller.php

namespace App\Http\Controllers;

use App\Models\Category;

use App\Setting;

use App\Post;

use function GuzzleHttp\Promise\all;

使用Illuminate \ Http \ Request;

首先从use App\Category;更改为use Category,再更改为use \Category,以使用App\Models\Category

第二个作曲家转储自动加载。

2 个答案:

答案 0 :(得分:0)

将其包括在您的类依赖项中:

use App\Category;

答案 1 :(得分:0)

您正在Category.php中使用两个名称空间

namespace App; //REMOVE THIS If model file is in app\Models folder
namespace App\Models; // Remove this if model file is in app(root) folder
use Illuminate\Database\Eloquent\Model;
class Category extends Model {......}