app/Http/Controllers/StudentDetailController.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)
    {
        $data = $request->validate([
            'ipa'=>'required|integer',
            'ips'=>'required|integer',
            'matematika'=>'required|integer'
        ]);
        $ipa = $request->ipa;
        $ips = $request->ips;
        $matematika = $request->matematika;
        $total = $ipa+$ips+$matematika;
        $detail = StudentDetail::findorFail($id);
        $detail->update($data);
        Student::findorFail($detail->student_id)->update(['nilai_total'=>$total]);
        return redirect()->route('home');
    }
public function update ( Request $ request , $ id ) { $ data = $ request -> validate ( [ 'ipa' => 'required|integer' , 'ips' => 'required|integer' , 'matematika' => 'required|integer' ] ) ; $ ipa = $ request -> ipa ; $ ips = $ request -> ips ; $ matematika = $ request -> matematika ; $ total = $ ipa + $ ips + $ matematika ; $ detail = StudentDetail :: findorFail ( $ id ) ; $ detail -> update ( $ data ) ; Student :: findorFail ( $ detail -> student_id ) -> update ( [ 'nilai_total' => $ total ] ) ; return redirect ( ) -> route ( 'home' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .