array_map()。参数#2应该是一个数组(一对一的关系更新)

<form method="POST" action="{{ route('profile.update') }}">
    @csrf
    <div class="card card-primary">
    <div class="card-header">
        <h3 class="card-title">
        <i class="fas fa-text-width"></i>
        Description
        </h3>
    </div>
    <!-- /.card-header -->
    <div class="card-body">
        <dl class="row">
        <dt class="col-sm-4">Nama</dt>
        <dd class="col-sm-6"><input type="text" name="name" class="form-control" value="{{ $user->name }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">NIP</dt>
        <dd class="col-sm-6"><input type="text" name="nip" class="form-control" value="{{ $user->nip }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">NUPTK</dt>
        <dd class="col-sm-6"><input type="text" name="nuptk" class="form-control" value="{{ $user->profile->nuptk }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Nomor Seri KARPEG</dt>
        <dd class="col-sm-6"><input type="text" name="no_seri_karpeg" class="form-control" value="{{ $user->profile->no_seri_karpeg }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Pangkat / Golongan Ruang / TMT</dt>
        <dd class="col-sm-2">
            <select name="pangkat" class="form-control" value="{{ $user->profile->pangkat }}">
                <option value="">Pilih Data</option>
                <option value="Penata Muda">Penata Muda</option>
                <option value="Penata Muda Tk.I">Penata Muda Tk.I</option>
                <option value="Penata">Penata</option>
                <option value="Penata Tk.I">Penata Tk.I</option>
                <option value="Pembina">Pembina</option>
                <option value="Pembina Tk.I">Pembina Tk.I</option>
                <option value="Pembina Utama Muda">Pembina Utama Muda</option>
                <option value="Pembina Utama Madya">Pembina Utama Madya</option>
                <option value="Pembina Utama">Pembina Utama</option>
            </select>
        </dd>
        <dd class="col-sm-2">
            <select name="golongan" class="form-control" value="{{ $user->profile->golongan }}">
                <option value="">Pilih Data</option>
                <option value="III">III</option>
                <option value="IV">IV</option>
            </select>
        </dd>
        <dd class="col-sm-2">
            <select name="golongan" class="form-control" value="{{ $user->profile->ruang }}">
                <option value="">Pilih Data</option>
                <option value="a">a</option>
                <option value="b">b</option>
                <option value="c">c</option>
                <option value="d">d</option>
                <option value="e">e</option>
            </select>
        </dd>
        <dd class="col-sm-2">
            <input type="text" name="tmt_pangkat" class="form-control" value="{{ $user->profile->tmt_pangkat }}" placeholder="Masukkan Data Anda">
        </dd>
        <dt class="col-sm-4">Jabatan / TMT</dt>
        <dd class="col-sm-3">
            <select name="jabatan" class="form-control" value="{{ $user->profile->jabatan }}">
                <option value="">Pilih Data</option>
                <option value="Guru Pertama">Guru Pertama</option>
                <option value="Guru Muda">Guru Muda</option>
                <option value="Guru Madya">Guru Madya</option>
                <option value="Guru Utama">Guru Utama</option>
            </select>
        </dd>
        <dd class="col-sm-3">
            <input type="text" name="tmt_jabatan" class="form-control" value="{{ $user->profile->tmt_jabatan }}" placeholder="Masukkan Data Anda">
        </dd>
        <dt class="col-sm-4">Tempat dan Tanggal Lahir</dt>
        <dd class="col-sm-3"><input type="text" name="" class="form-control" value="{{ $user->profile->tempat_lahir }}" placeholder="Masukkan Data Anda"></dd>
        <dd class="col-sm-3"><input type="text" name="" class="form-control" value="{{ $user->profile->tanggal_lahir }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Jenis Kelamin</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->jk }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Pendidikan Tertinggi</dt>
        <dd class="col-sm-3">
            <select name="pendidikan_jurusan" class="form-control" value="{{ $user->profile->pendidikan_jurusan }}">
                <option value="">Pilih Data</option>
                <option value="SD">SD</option>
                <option value="SMP">SMP</option>
                <option value="SMA/SMK">SMA/SMK</option>
                <option value="D-I">D-I</option>
                <option value="D-II">D-II</option>
                <option value="D-IV">D-IV</option>
                <option value="S-I">S-I</option>
                <option value="S-II">S-II</option>
                <option value="S-III">S-III</option>
            </select>
        </dd>
        <dd class="col-sm-3">
            <input type="text" name="pendidikan_jurusan" class="form-control" value="{{ $user->profile->pendidikan_jurusan }}" placeholder="Masukkan Data Anda"> 
        </dd>
        <dt class="col-sm-4">Jabatan Fungsional / TMT</dt>
        <dd class="col-sm-3">
            <input type="text" name="jabatan_fungsional" class="form-control" value="{{ $user->profile->jabatan_fungsional }}" placeholder="Masukkan Data Anda"> 
        </dd>
        <dd class="col-sm-3">
            <input type="text" name="tmt_jabatan_fungsional" class="form-control" value="{{ $user->profile->tmt_jabatan_fungsional }}" placeholder="Masukkan Data Anda"> 
        </dd>
        <dt class="col-sm-4">Masa Kerja Golongan Lama</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->masa_kerja_lama }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Jenis Guru</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->jenis_guru }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Mengajar Kelas</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->lama_mengajar }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Unit Kerja</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->unit_kerja }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Gaji Pokok Lama</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->gaji_lama }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-4">Jabatan/TMT/Jumlah AK Lama</dt>
        <dd class="col-sm-6"><input type="text" name="" class="form-control" value="{{ $user->profile->jumlah_ak_lama }}" placeholder="Masukkan Data Anda"></dd>
        </dl>
    </div>
    <!-- /.card-body -->
    </div>
    <!-- /.card -->
    <div class="card card-primary">
    <div class="card-header">
        <h3 class="card-title">
        <i class="fas fa-text-width"></i>
        Tempat Tinggal
        </h3>
    </div>
    <!-- /.card-header -->
    <div class="card-body">
        <dl class="row">
        <dt class="col-sm-3">Alamat</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->alamat }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-3">Provinsi</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->provinsi }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-3">Kota</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->kota }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-3">Kelurahan</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->kelurahan }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-3">Kecamatan</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->kecamatan }}" placeholder="Masukkan Data Anda"></dd>
        <dt class="col-sm-3">Kode Pos</dt>
        <dd class="col-sm-8"><input type="text" name="" class="form-control" value="{{ $user->profile->kode_pos }}" placeholder="Masukkan Data Anda"></dd>
        </dl>
    </div>
    <!-- /.card-body -->
    </div>
    <!-- /.card -->
    <button type="submit" class="btn btn-lg btn-success">Perbaharui Data</button>
</form>

你好,伙计们帮我这个错误,我试图更新配置文件表与用户关系,我卡在控制器上我的模型是正确的,可以帮助我。有我的视图代码和我的控制器页面,如果你需要我的模型页面,我会给它以后,我只专注于控制器

public function update(Request $request, $id = null, User $user, Profile $profile)
{
    $userId = $id ?: auth()->user()->id;
    $user = User::with('profile')->findOrFail($userId);

    $request->validate($request->all());

    $user = User::update($request->all());
    $profile= Profile::update($request->all());
    return route('profile')->with('success','Updated');
}

错误显示

谢谢你的帮助

解决方案:

正如你在stacktrace中看到的那样,这与验证的错误有关。该 validate() 方法将验证规则作为输入,它在请求的上下文中已经有了输入,所以你不必传递它。

$request->validate([
    'jabatan' => ['required', 'string'],
    // ... more rules
]);

如果你想得到所有需要的东西,你可以用map映射每个输入。

$rules = array_map(function () {
    return ['required'];
}, $request->all());

$request->validate($rules);

给TA打赏
共{{data.count}}人
人已打赏
解决方案

在wpf中启动故事板后停止故事板。

2022-5-12 13:00:21

解决方案

在Python中随机交换两个列表。

2022-5-12 13:00:27

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索