app/Http/Controllers/CategoryController.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(Request $request)
    {
        $image = '';
        if ($request->hasFile('image')) {
            $image = time() . '.' . request()->image->getClientOriginalExtension();
            request()->image->move(public_path('images/category/'), $image);
        }
        $category = $request->all();
        $category['image'] = $image;
        if (Category::create($category)) {
            return redirect()->route('category.index')->with('success', 'Category created successfully');
        }
        return redirect()->back()->with('failed', 'Some error occured!! Please try again');
    }
public function store ( Request $ request ) { $ image = '' ; if ( $ request -> hasFile ( 'image' ) ) { $ image = time ( ) . '.' . request ( ) -> image -> getClientOriginalExtension ( ) ; request ( ) -> image -> move ( public_path ( 'images/category/' ) , $ image ) ; } $ category = $ request -> all ( ) ; $ category [ 'image' ] = $ image ; if ( Category :: create ( $ category ) ) { return redirect ( ) -> route ( 'category.index' ) -> with ( 'success' , 'Category created successfully' ) ; } return redirect ( ) -> back ( ) -> with ( 'failed' , 'Some error occured!! Please try again' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .