首先,我想說我在 SO 中找到的解決方案中嘗試了類似的問題。
我剛剛重新遷移,問題開始了......嘗試過 composer update 和 composer dump-autoload 和 npm update vue-loader 沒有幫助。用戶模型似乎有問題,但我數數弄清楚出了什么問題。
用戶模型:
<?php namespace App\Models; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\users as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class users extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var string[] */ protected $fillable = [ 'first_name', 'last_name', 'username', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; }
控制器:
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use App\Models\users; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; class RegisterController extends Controller { /* |-------------------------------------------------------------------------- | Register Controller |-------------------------------------------------------------------------- | | This controller handles the registration of new users as well as their | validation and creation. By default this controller uses a trait to | provide this functionality without requiring any additional code. | */ use RegistersUsers; /** * Where to redirect users after registration. * * @var string */ protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest'); } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'first_name' => ['required', 'string', 'max:255'], 'last_name' => ['required', 'string', 'max:255'], 'username' => ['required', 'string', 'max:255'], 'password' => ['required', 'string', 'min:8', 'confirmed'], ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return \App\Models\users */ protected function create(array $data) { return users::create([ 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'username' => $data['username'], 'password' => Hash::make($data['password']), ]); } }
uj5u.com熱心網友回復:
在模型中替換use Illuminate\Foundation\Auth\users as Authenticatable為。use Illuminate\Foundation\Auth\User as AuthenticatableUser
因為沒有users在課堂上Auth。
讓我知道它是否解決了您的問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/331012.html
上一篇:Laravel7未定義的方法
