app/Http/Controllers/Admin/courseController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(CourseValidator $request)
    {
        if ($request->hasFile('image')) {
            $image = $request->file('image');
            $images = "image-" . time() . '.' . $image->getClientOriginalExtension();
            $image->move('images/course/', $images);
            }
            $course = new Course([
                'name' => $request->name,
                'duration' => $request->duration,
                'fees' => $request->fees,
                'description' => $request->description
            ]);
            $course->image = $images;
            $course->save();
        return redirect()->route('course.index')->with('success', 'Course Created Successfully');
    }
public function store ( CourseValidator $ request ) { if ( $ request -> hasFile ( 'image' ) ) { $ image = $ request -> file ( 'image' ) ; $ images = " image- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/course/' , $ images ) ; } $ course = new Course ( [ 'name' => $ request -> name , 'duration' => $ request -> duration , 'fees' => $ request -> fees , 'description' => $ request -> description ] ) ; $ course -> image = $ images ; $ course -> save ( ) ; return redirect ( ) -> route ( 'course.index' ) -> with ( 'success' , 'Course Created Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .