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(EditMahasiswaRequest $request, $id)
    {
        $data_mahasiswa = Mahasiswa::find($id);
        $data_mahasiswa->update($request->all());
        if($request->hasFile('avatar')) {
            $request->file('avatar')->move('images/', $request->file('avatar')->getClientOriginalName());
            $data_mahasiswa->avatar = $request->file('avatar')->getClientOriginalName();
            $data_mahasiswa->save();
        }
        return redirect('/mahasiswa')->with('sukses','Data Berhasil di update');
    }
public function update ( EditMahasiswaRequest $ request , $ id ) { $ data_mahasiswa = Mahasiswa :: find ( $ id ) ; $ data_mahasiswa -> update ( $ request -> all ( ) ) ; if ( $ request -> hasFile ( 'avatar' ) ) { $ request -> file ( 'avatar' ) -> move ( 'images/' , $ request -> file ( 'avatar' ) -> getClientOriginalName ( ) ) ; $ data_mahasiswa -> avatar = $ request -> file ( 'avatar' ) -> getClientOriginalName ( ) ; $ data_mahasiswa -> save ( ) ; } return redirect ( '/mahasiswa' ) -> with ( 'sukses' , 'Data Berhasil di update' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .