app/Http/Controllers/KaryawanController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\karyawan  $karyawan
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $req)
    {
        $foto = $req->file('foto_ktp')->getClientOriginalName();
        $foto_karyawan = $req->file('foto_karyawan')->getClientOriginalName();
        $karyawans = karyawan::where('id',$req->id)->update([
        "nama"=>$req->input('nama'),
        "nik"=>$req->input('nik'),
        "no_npwp"=>$req->input('no_npwp'),
        "no_bpjs_ketenagakerjaan"=>$req->input('no_bpjs_ketenagakerjaan'),
        "no_bpjs_kesehatan"=>$req->input('no_bpjs_kesehatan'),
        "tanggal_lahir"=>$req->input('tanggal_lahir'),
        "wilayah_id"=>$req->input('wilayah_id'),
        "unit_kerja_id"=>$req->input('unit_kerja_id'),
        "bidang_tugas"=>$req->input('bidang_tugas'),
        "pendidikan_formal"=>$req->input('pendidikan_formal'),
        "honor"=>$req->input('honor'),
        "jenis_kelamin"=>$req->input('jenis_kelamin'),
        "alamat_domisili"=>$req->input('alamat_domisili'),
        "alamat_ktp"=>$req->input('alamat_ktp'),
        "foto_karyawan"=>$req->file('foto_karyawan')->move(public_path('uploads'),$foto_karyawan),
        "foto_ktp"=>$req->file('foto_ktp')->move(public_path('uploads'),$foto),
        "perjanjian_kerja"=>$req->input('perjanjian_kerja'),
        "kontrak"=>$req->input('kontrak'),
        "vaksin"=>$req->input('vaksin'),
        "no_rekening"=>$req->input('no_rekening'),
        "nama_bank"=>$req->input('nama_bank')
    ]);
        if($karyawans){
            return redirect('/karyawan');
        }else {
            return back();
        }
    }
public function update ( Request $ req ) { $ foto = $ req -> file ( 'foto_ktp' ) -> getClientOriginalName ( ) ; $ foto_karyawan = $ req -> file ( 'foto_karyawan' ) -> getClientOriginalName ( ) ; $ karyawans = karyawan :: where ( 'id' , $ req -> id ) -> update ( [ " nama " => $ req -> input ( 'nama' ) , " nik " => $ req -> input ( 'nik' ) , " no_npwp " => $ req -> input ( 'no_npwp' ) , " no_bpjs_ketenagakerjaan " => $ req -> input ( 'no_bpjs_ketenagakerjaan' ) , " no_bpjs_kesehatan " => $ req -> input ( 'no_bpjs_kesehatan' ) , " tanggal_lahir " => $ req -> input ( 'tanggal_lahir' ) , " wilayah_id " => $ req -> input ( 'wilayah_id' ) , " unit_kerja_id " => $ req -> input ( 'unit_kerja_id' ) , " bidang_tugas " => $ req -> input ( 'bidang_tugas' ) , " pendidikan_formal " => $ req -> input ( 'pendidikan_formal' ) , " honor " => $ req -> input ( 'honor' ) , " jenis_kelamin " => $ req -> input ( 'jenis_kelamin' ) , " alamat_domisili " => $ req -> input ( 'alamat_domisili' ) , " alamat_ktp " => $ req -> input ( 'alamat_ktp' ) , " foto_karyawan " => $ req -> file ( 'foto_karyawan' ) -> move ( public_path ( 'uploads' ) , $ foto_karyawan ) , " foto_ktp " => $ req -> file ( 'foto_ktp' ) -> move ( public_path ( 'uploads' ) , $ foto ) , " perjanjian_kerja " => $ req -> input ( 'perjanjian_kerja' ) , " kontrak " => $ req -> input ( 'kontrak' ) , " vaksin " => $ req -> input ( 'vaksin' ) , " no_rekening " => $ req -> input ( 'no_rekening' ) , " nama_bank " => $ req -> input ( 'nama_bank' ) ] ) ; if ( $ karyawans ) { return redirect ( '/karyawan' ) ; } else { return back ( ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .