在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
。
第二个作曲家转储自动加载。
您在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 {......}
将它包含在您的类依赖项中:
use App\Category;