在注册我的用户模型期间尝试将用户的详细信息插入多个表时,出现 404 错误:
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
class User extends Authenticatable
{
use Notifiable;
use HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'username','accno', 'email', 'password', 'role', 'status', 'activation_code'
];
protected $guarded = [];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', …Run Code Online (Sandbox Code Playgroud) 在我的接收视图模型中,我想在异步方法 GetMovies() 中引用 [QueryParameter] 并运行它以用电影填充页面。我已将断点放置在 MovieListGenrePageViewModel 中的 GetMovies 方法处。调用时, selectedGenre 为 null,但已在 {Binding} 中返回。我缺少什么?
using System.Collections.ObjectModel;
using System.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
using TimesNewsApp.Models;
using TimesNewsApp.Services;
namespace TimesNewsApp.ViewModels
{
[QueryProperty(nameof(SelectedGenre), nameof(SelectedGenre))]
public partial class MovieListGenrePageViewModel : BaseViewModel
{
public ObservableCollection<Result> Movie { get;} = new();
private Genre selectedGenre;
public Genre SelectedGenre
{
get => selectedGenre;
set
{
SetProperty(ref selectedGenre, value);
}
}
NewsApiManager apiService;
public Command GetMovieComand { get; }
public MovieListGenrePageViewModel(NewsApiManager apiService)
{
this.apiService = apiService;
Task.Run(async () => await GetMovies(SelectedGenre)); …Run Code Online (Sandbox Code Playgroud) 在我的控制器中,我创建了一个函数来验证用户并通过邮件通知
protected function register(Request $request)
{
/** @var User $user */
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
try {
$validatedData['password'] = bcrypt(array_get($validatedData, 'password'));
$validatedData['activation_code'] = str_random(30).time();
$user = app(User::class)->create($validatedData);
} catch (\Exception $exception) {
logger()->error($exception);
return redirect()->back()->with('message', 'Unable to create new user.');
}
$user->notify(new UserRegisteredSuccessfully($user));
return redirect()->back()->with('message', 'Successfully created a new account. Please check your email and activate your account.');
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我不断收到此错误 Call to undefined function App\Http\Controllers\Auth\array_get() 有人可以教我如何解决此错误吗?
非常感谢提前。