app/Http/Controllers/SubCategoryController.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/subcategory/'), $image);
        }
        $subcategory = $request->all();
        $subcategory['image'] = $image;
        if (SubCategory::create($subcategory)) {
            return redirect()->route('subcategory.index')->with('success', 'Sub 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/subcategory/' ) , $ image ) ; } $ subcategory = $ request -> all ( ) ; $ subcategory [ 'image' ] = $ image ; if ( SubCategory :: create ( $ subcategory ) ) { return redirect ( ) -> route ( 'subcategory.index' ) -> with ( 'success' , 'Sub 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 .