app/Http/Controllers/Admin/courseController.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(CourseValidator $request, $id)
    {
        $course = Course::findorfail($id);
        if ($request->hasFile('image')) {
            $new_img = $request->file('image');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/course/',$name);
            $course->image = $name;    
        }else{
            $course->image = $name;
        }
        $course->name = $request->input('name');
        $course->duration = $request->input('duration');
        $course->fees = $request->input('fees');
        $course->description = $request->input('description');
        $course->save();
        return redirect()->route('course.index')->with('success', 'Course Updated Successfully');
    }
public function update ( CourseValidator $ request , $ id ) { $ course = Course :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ new_img = $ request -> file ( 'image' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/course/' , $ name ) ; $ course -> image = $ name ; } else { $ course -> image = $ name ; } $ course -> name = $ request -> input ( 'name' ) ; $ course -> duration = $ request -> input ( 'duration' ) ; $ course -> fees = $ request -> input ( 'fees' ) ; $ course -> description = $ request -> input ( 'description' ) ; $ course -> save ( ) ; return redirect ( ) -> route ( 'course.index' ) -> with ( 'success' , 'Course Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .