为了账号安全,请及时绑定邮箱和手机立即绑定

Laravel Vue api 给出内部 500 服务器错误 App\User not found

Laravel Vue api 给出内部 500 服务器错误 App\User not found

PHP
qq_笑_17 2023-09-22 16:19:08
无法发布到 phpmyadmin。在当地工作。总体而言,该站点路由良好。我尝试将模型添加到 auth.php 文件中,并更改 user.php 中的命名空间以包含其他论坛以及 stackoverflow 中建议的模型。这不起作用。我在网络选项卡中收到以下错误:{message: "Class 'APP\User' not found", exception: "Error",…}exception: "Error"file: "C:\laragon\www\crm\app\Http\Controllers\API\UserController.php"line: 31message: "Class 'APP\User' not found"trace: [{function: "store", class: "App\Http\Controllers\API\UserController", type: "->"},…]这是我现在的文件:用户.php<?phpnamespace App;use Illuminate\Contracts\Auth\MustVerifyEmail;use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;class User extends Authenticatable{    use Notifiable;    /**     * The attributes that are mass assignable.     *     * @var array     */    protected $fillable = [        'name', 'email', 'password', 'bio', 'photo', 'type'    ];    /**     * The attributes that should be hidden for arrays.     *     * @var array     */    protected $hidden = [        'password', 'remember_token',    ];    /**     * The attributes that should be cast to native types.     *     * @var array     */    protected $casts = [        'email_verified_at' => 'datetime',    ];}auth.php 中的身份验证提供者部分 'providers' => [        'users' => [            'driver' => 'eloquent',            'model' => App\User::class,        ],我正在使用 Laravel 学习 VueJs 的旧教程,但他们使用的是 Laravel 5.7,而我使用的是 Laravel 7。我确信很多事情都发生了变化,所以如果有人可以为此提供一些帮助,我肯定会很感激。先感谢您。
查看完整描述

1 回答

?
一只萌萌小番薯

TA贡献1795条经验 获得超7个赞

您的导入UserController.php应该是use App\User;App需要小写。



查看完整回答
反对 回复 2023-09-22
  • 1 回答
  • 0 关注
  • 43 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信