app/Http/Controllers/Admin/studentController.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(StudentValidator $request, $id)
    {
        $student = Student::findorfail($id);
        if ($request->hasFile('image')) {
            $new_img = $request->file('image');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/student/',$name);
            $student->image = $name;    
        }else{
            $student->image = Auth::user()->image;
        }  
        $student->fname = $request->input('fname');
        $student->lname = $request->input('lname');
        $student->dob = $request->input('dob');
        $student->gender = $request->input('gender');
        $student->email = $request->input('email');
        $student->stdcat = $request->input('stdcat');
        $student->phone = $request->input('phone');
        $student->batch = $request->input('batch');
        $student->section = $request->input('section');
        $student->course = $request->input('course');
        $student->address = $request->input('address');
        $student->save();
        return redirect()->route('student.index')->with('success', 'Student Updated Successfully');
    }
public function update ( StudentValidator $ request , $ id ) { $ student = Student :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ new_img = $ request -> file ( 'image' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/student/' , $ name ) ; $ student -> image = $ name ; } else { $ student -> image = Auth :: user ( ) -> image ; } $ student -> fname = $ request -> input ( 'fname' ) ; $ student -> lname = $ request -> input ( 'lname' ) ; $ student -> dob = $ request -> input ( 'dob' ) ; $ student -> gender = $ request -> input ( 'gender' ) ; $ student -> email = $ request -> input ( 'email' ) ; $ student -> stdcat = $ request -> input ( 'stdcat' ) ; $ student -> phone = $ request -> input ( 'phone' ) ; $ student -> batch = $ request -> input ( 'batch' ) ; $ student -> section = $ request -> input ( 'section' ) ; $ student -> course = $ request -> input ( 'course' ) ; $ student -> address = $ request -> input ( 'address' ) ; $ student -> save ( ) ; return redirect ( ) -> route ( 'student.index' ) -> with ( 'success' , 'Student Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .