app/Http/Controllers/kategorylemburController.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)
    {
        $lembur=Kategorylembur::where('id',$id)->first();
        if($lembur['kode_lembur'] != Request('kode_lembur')){
        $rules=[
                'kode_lembur'=>'required|unique:kategory_lemburs,kode_lembur',
                'golongan_id'=>'required',
                'besaran_uang'=>'required',
                'jabatan_id'=>'required',
                ];
        }
        else{
        $rules=[
                'kode_lembur'=>'required',
                'golongan_id'=>'required',
                'jabatan_id'=>'required',
                ];
        }
        $sms=[
                'kode_lembur.required'=>'SILAHKAN DI ISI',
                'besaran_uang.required'=>'SILAHKAN DI ISI',
                'kode_lembur.unique'=>'SILAHKAN DI ISI',
                'golongan_id.required'=>'SILAHKAN DI ISI',
                'jabatan_id.required'=>'SILAHKAN DI ISI',
                ];
        $validasi=Validator::make(Input::all(),$rules,$sms);
        if($validasi->fails()){
            return redirect()->back()
            ->WithErrors($validasi)
            ->WithInput();
        }
        $lemburupdate=Request::all();
        $lembur=Kategorylembur::find($id);
        $lembur->update($lemburupdate);
        return redirect('lemburkate');
    }
public function update ( Request $ request , $ id ) { $ lembur = Kategorylembur :: where ( 'id' , $ id ) -> first ( ) ; if ( $ lembur [ 'kode_lembur' ] != Request ( 'kode_lembur' ) ) { $ rules = [ 'kode_lembur' => 'required|unique:kategory_lemburs,kode_lembur' , 'golongan_id' => 'required' , 'besaran_uang' => 'required' , 'jabatan_id' => 'required' , ] ; } else { $ rules = [ 'kode_lembur' => 'required' , 'golongan_id' => 'required' , 'jabatan_id' => 'required' , ] ; } $ sms = [ 'kode_lembur.required' => 'SILAHKAN DI ISI' , 'besaran_uang.required' => 'SILAHKAN DI ISI' , 'kode_lembur.unique' => 'SILAHKAN DI ISI' , 'golongan_id.required' => 'SILAHKAN DI ISI' , 'jabatan_id.required' => 'SILAHKAN DI ISI' , ] ; $ validasi = Validator :: make ( Input :: all ( ) , $ rules , $ sms ) ; if ( $ validasi -> fails ( ) ) { return redirect ( ) -> back ( ) -> WithErrors ( $ validasi ) -> WithInput ( ) ; } $ lemburupdate = Request :: all ( ) ; $ lembur = Kategorylembur :: find ( $ id ) ; $ lembur -> update ( $ lemburupdate ) ; return redirect ( 'lemburkate' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//