app/Http/Controllers/tunjanganController.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)
    {
        $tunjangan=Tunjangan::where('id',$id)->first();
        if($tunjangan['kode_tunjangan'] != Request('kode_tunjangan')){
            $roles=[
                'kode_tunjangan'=>'required|unique:tunjangans',
                'jabatan_id'=>'required',
                'golongan_id'=>'required',
                'besaran_uang'=>'required',
                'jumlah_anak'=>'required',
                'status'=>'required',
            ];
        }
        else{
            $roles=[
                'kode_tunjangan'=>'required',
                'jabatan_id'=>'required',
                'golongan_id'=>'required',
                'besaran_uang'=>'required',
                'jumlah_anak'=>'required',
                'status'=>'required',
            ];
        }
        $sms=[
                'kode_tunjangan.required'=>'HARAP DI ISI',
                'kode_tunjangan.unique'=>'SUDAH ADA',
                'jabatan_id.required'=>'HARAP DI ISI',
                'golongan_id.required'=>'HARAP DI ISI',
                'besaran_uang.required'=>'HARAP DI ISI',
                'status.required'=>'HARAP DI ISI',
                'jumlah_anak.required'=>'HARAP DI ISI',
            ];
            $validasi= Validator::make(Input::all(),$roles,$sms);
            if($validasi->fails()){
                return redirect()->back()
                        ->WithErrors($validasi)
                        ->WithInput();
            }
            $update=Request::all();
            $tunjangan=Tunjangan::find($id);
            $tunjangan->update($update);
            return redirect('tunjangan');
    }
public function update ( Request $ request , $ id ) { $ tunjangan = Tunjangan :: where ( 'id' , $ id ) -> first ( ) ; if ( $ tunjangan [ 'kode_tunjangan' ] != Request ( 'kode_tunjangan' ) ) { $ roles = [ 'kode_tunjangan' => 'required|unique:tunjangans' , 'jabatan_id' => 'required' , 'golongan_id' => 'required' , 'besaran_uang' => 'required' , 'jumlah_anak' => 'required' , 'status' => 'required' , ] ; } else { $ roles = [ 'kode_tunjangan' => 'required' , 'jabatan_id' => 'required' , 'golongan_id' => 'required' , 'besaran_uang' => 'required' , 'jumlah_anak' => 'required' , 'status' => 'required' , ] ; } $ sms = [ 'kode_tunjangan.required' => 'HARAP DI ISI' , 'kode_tunjangan.unique' => 'SUDAH ADA' , 'jabatan_id.required' => 'HARAP DI ISI' , 'golongan_id.required' => 'HARAP DI ISI' , 'besaran_uang.required' => 'HARAP DI ISI' , 'status.required' => 'HARAP DI ISI' , 'jumlah_anak.required' => 'HARAP DI ISI' , ] ; $ validasi = Validator :: make ( Input :: all ( ) , $ roles , $ sms ) ; if ( $ validasi -> fails ( ) ) { return redirect ( ) -> back ( ) -> WithErrors ( $ validasi ) -> WithInput ( ) ; } $ update = Request :: all ( ) ; $ tunjangan = Tunjangan :: find ( $ id ) ; $ tunjangan -> update ( $ update ) ; return redirect ( 'tunjangan' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//