app/Http/Controllers/TunjanganpController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $tunjanganp=TunjanganPegawai::where('id',$id)->first();
        if($tunjanganp['kode_tunjangan_id'] != Request('kode_tunjangan_id')){
            $roles=[
                'kode_tunjangan_id'=>'required|unique:tunjangan_pegawais',
                'pegawai_id'=>'required',
            ];
        }
        else{
            $roles=[
                'kode_tunjangan_id'=>'required',
                'pegawai_id'=>'required',
            ];
        }
        $sms=[
                'kode_tunjangan_id.required'=>'HARAP DI ISI',
                'kode_tunjangan_id.unique'=>'SUDAH ADA',
                'pegawai_id.required'=>'HARAP DI ISI',
            ];
            $validasi= Validator::make(Input::all(),$roles,$sms);
            if($validasi->fails()){
                return redirect()->back()
                        ->WithErrors($validasi)
                        ->WithInput();
            }
            $update=Request::all();
            $tunjanganp=TunjanganPegawai::find($id);
            $tunjanganp->update($update);
            return redirect('tunjangpegawai');
    }
public function update ( Request $ request , $ id ) { $ tunjanganp = TunjanganPegawai :: where ( 'id' , $ id ) -> first ( ) ; if ( $ tunjanganp [ 'kode_tunjangan_id' ] != Request ( 'kode_tunjangan_id' ) ) { $ roles = [ 'kode_tunjangan_id' => 'required|unique:tunjangan_pegawais' , 'pegawai_id' => 'required' , ] ; } else { $ roles = [ 'kode_tunjangan_id' => 'required' , 'pegawai_id' => 'required' , ] ; } $ sms = [ 'kode_tunjangan_id.required' => 'HARAP DI ISI' , 'kode_tunjangan_id.unique' => 'SUDAH ADA' , 'pegawai_id.required' => 'HARAP DI ISI' , ] ; $ validasi = Validator :: make ( Input :: all ( ) , $ roles , $ sms ) ; if ( $ validasi -> fails ( ) ) { return redirect ( ) -> back ( ) -> WithErrors ( $ validasi ) -> WithInput ( ) ; } $ update = Request :: all ( ) ; $ tunjanganp = TunjanganPegawai :: find ( $ id ) ; $ tunjanganp -> update ( $ update ) ; return redirect ( 'tunjangpegawai' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//