得到问题“类'应用程序/类别'未找到”它

问题描述 投票:0回答:2

在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

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

laravel-5 laravel-5.2 laravel-5.1
2个回答
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 {......}

0
投票

将它包含在您的类依赖项中:

use App\Category;
© www.soinside.com 2019 - 2024. All rights reserved.