首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >类“照明\基金会\8月\学生”未在laravel新版本中找到错误

类“照明\基金会\8月\学生”未在laravel新版本中找到错误
EN

Stack Overflow用户
提问于 2022-07-06 10:05:41
回答 1查看 104关注 0票数 -1

我对laravel框架很陌生,我正在尝试将记录插入用户表和users表中。以下查询在users表中有效,但在后者中显示错误类“照明\Foundation\Auth\Student”未找到。有人能帮帮我吗。我在这里搜索了类似的查询,但不幸的是对我不起作用。这是我的密码。

FrondEndController.php

代码语言:javascript
复制
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use App\Models\Student;
class FrondEndController extends Controller
{
public function homepage(){
$users=User::all();// select *from users;
$q1= User::insert(['name' => 'DR Robin', 'password' =>'winner']);
$q2= Student::insert(['Studentname' => 'DR Robin', 'email' =>'robin@gmail.com']);
$User_Update = User::where("id", '2')->update(["password" =>"eternallove"]);
return $users;
return view('welcome');
}
}

Student.php(模型)

代码语言:javascript
复制
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\Student as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class Student extends Authenticatable
{
protected $table = 'students';
use HasApiTokens, HasFactory, Notifiable;
protected $fillable = [
'name',
'email',
'password',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}

auth.php

代码语言:javascript
复制
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver'=>'passport',
'provider'=>'Students'
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'Students' => [
'driver' => 'eloquent',
'model' => App\Student::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
 ],
 ],
'password_timeout' => 10800,
];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-06 10:19:27

您必须将use Illuminate\Foundation\Auth\Student as Authenticatable;替换为use Illuminate\Foundation\Auth\User as Authenticatable;

Student.php

代码语言:javascript
复制
<?php
...
...
...
use Illuminate\Foundation\Auth\User as Authenticatable;
...
...
...
class Student extends Authenticatable
{
protected $table = 'students';
use HasApiTokens, HasFactory, Notifiable;
protected $fillable = [
'name',
'email',
'password',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72881570

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档