app/Http/Controllers/MahasiswaController.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, $Nim)
    {
            $request->validate([
                'Nim' => 'required',
                'Nama' => 'required',
                'Kelas' => 'required',
                'Jurusan' => 'required',
                'No_Handphone' => 'required',
                'E_Mail' => 'required',
                'TglLahir' => 'required',
                ]);
                Mahasiswa::find($Nim)->update($request->all());
                return redirect()->route('mahasiswas.index')
                    ->with('success', 'Mahasiswa Berhasil Diupdate');
    }
public function update ( Request $ request , $ Nim ) { $ request -> validate ( [ 'Nim' => 'required' , 'Nama' => 'required' , 'Kelas' => 'required' , 'Jurusan' => 'required' , 'No_Handphone' => 'required' , 'E_Mail' => 'required' , 'TglLahir' => 'required' , ] ) ; Mahasiswa :: find ( $ Nim ) -> update ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'mahasiswas.index' ) -> with ( 'success' , 'Mahasiswa Berhasil Diupdate' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//melakukan validasi data //fungsi eloquent untuk mengupdate data inputan kita //jika data berhasil diupdate, akan kembali ke halaman utama