带有 Inertia.js 堆栈的 laravel 8 jetstream 未更新配置文件信息

问题描述

我将 laravel 8 与 jetstream 与 Inertia.js Stack 一起使用。 我的数据库字段名称在snake_case 中,我在模板中使用了camelCase。我在配置文件添加了新字段,如测试、关于、显示名称和点。我可以成功保存所有输入的日期,但是当我刷新时,我可以看到显示名称没有带来数据。不知道为什么会这样,如果我将模板和数据库中的 display_name 更改为 snkae_case,那么它会将所有保存的信息带回显示配置文件。任何人都可以请指导我这一点。

更新UserProfileinformation.PHP

<?PHP

namespace App\Actions\Fortify;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\UpdatesUserProfileinformation;

class UpdateUserProfileinformation implements UpdatesUserProfileinformation
{
    /**
     * Validate and update the given user's profile information.
     *
     * @param  mixed  $user
     * @param  array  $input
     * @return void
     */
    public function update($user,array $input)
    {
        Validator::make($input,[
            'name' => ['required','string','max:255'],'email' => ['required','email','max:255',Rule::unique('users')->ignore($user->id)],'photo' => ['nullable','image','max:1024'],])->validateWithBag('updateProfileinformation');

        if (isset($input['photo'])) {
            $user->updateProfilePhoto($input['photo']);
        }

        if ($input['email'] !== $user->email &&
            $user instanceof MustVerifyEmail) {
            $this->updateVerifiedUser($user,$input);
        } else {

            $user->forceFill([
                'name' => $input['name'],'email' => $input['email'],'about'=> $input['about'],'display_name'=> $input['displayName'],'points'=> $input['points'],'test'=> $input['test'],])->save();

        }
    }

    /**
     * Update the given verified user's profile information.
     *
     * @param  mixed  $user
     * @param  array  $input
     * @return void
     */
    protected function updateVerifiedUser($user,array $input)
    {
        $user->forceFill([
            'name' => $input['name'],'email_verified_at' => null,])->save();

        $user->sendEmailVerificationNotification();
    }
}

这是 UpdateProfileinformationForm.vue

 <div class="col-span-6 sm:col-span-4">
            <jet-label for="name" value="Name" />
            <jet-input id="name" type="text" class="mt-1 block w-full" v-model="form.name" autocomplete="name" />
            <jet-input-error :message="form.error('name')" class="mt-2" />
        </div>

        <!-- Email -->
        <div class="col-span-6 sm:col-span-4">
            <jet-label for="email" value="Email" />
            <jet-input id="email" type="email" class="mt-1 block w-full" v-model="form.email" />
            <jet-input-error :message="form.error('email')" class="mt-2" />
        </div>

        <!-- About -->
        <div class="col-span-6 sm:col-span-4">
            <jet-label for="about" value="About" />
            <jet-input id="about" type="text" class="mt-1 block w-full" v-model="form.about" autocomplete="about" />
            <jet-input-error :message="form.error('about')" class="mt-2" />
        </div>

        <!-- display Name -->
        <div class="col-span-6 sm:col-span-4">
            <jet-label for="displayName" value="display Name" />
            <jet-input id="displayName" type="text" class="mt-1 block w-full" v-model="form.displayName" autocomplete="displayName" />
            <jet-input-error :message="form.error('display_name')" class="mt-2" />
        </div>

        <!-- Total Points -->
        <div class="col-span-6 sm:col-span-4">
            <jet-label for="points" value="Points" />
            <jet-input id="points" type="text" class="mt-1 block w-full" v-model="form.points" autocomplete="points" />
            <jet-input-error :message="form.error('totalPoints')" class="mt-2" />
        </div>


        <!-- Test -->
        <div class="col-span-6 sm:col-span-4">
            <jet-label for="test" value="test" />
            <jet-input id="test" type="text" class="mt-1 block w-full" v-model="form.test" autocomplete="test" />
            <jet-input-error :message="form.error('test')" class="mt-2" />
        </div>

    </template>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)