app/Http/Controllers/sparesController.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(SpareDataRequest $request)
    {
        $Spare = new Spares;
        $Spare->model_id = $request->get('modelId');
        $Spare->brand_id = $request->get('brandId');
        $Spare->category_id = $request->get('categoryId');
        $Spare->partNumber = $request->get('partNumber');
        $Spare->warranty = $request->get('warranty');
        $Spare->retailer_id = $request->get('retailerId');
        $Spare->quantity = $request->get('quantity');
        $Spare->cost=$request->get('cost');
        $Spare->price = $request->get('price');
        $Spare->description = $request->get('description');
        if ($file = $request->hasFile('spareImage')) {
            $file = $request->file('spareImage');
            $fileName = $file->getClientOriginalName();
            $destinationPath = public_path() . '/images/spares';
            $file->move($destinationPath, $fileName);
            $Spare->imagePath = $fileName;
        }
        $Spare->save();
        \Session::flash('flash_message', 'Added new Spare.'); 
        return redirect()->back();
    }
public function store ( SpareDataRequest $ request ) { $ Spare = new Spares ; $ Spare -> model_id = $ request -> get ( 'modelId' ) ; $ Spare -> brand_id = $ request -> get ( 'brandId' ) ; $ Spare -> category_id = $ request -> get ( 'categoryId' ) ; $ Spare -> partNumber = $ request -> get ( 'partNumber' ) ; $ Spare -> warranty = $ request -> get ( 'warranty' ) ; $ Spare -> retailer_id = $ request -> get ( 'retailerId' ) ; $ Spare -> quantity = $ request -> get ( 'quantity' ) ; $ Spare -> cost = $ request -> get ( 'cost' ) ; $ Spare -> price = $ request -> get ( 'price' ) ; $ Spare -> description = $ request -> get ( 'description' ) ; if ( $ file = $ request -> hasFile ( 'spareImage' ) ) { $ file = $ request -> file ( 'spareImage' ) ; $ fileName = $ file -> getClientOriginalName ( ) ; $ destinationPath = public_path ( ) . '/images/spares' ; $ file -> move ( $ destinationPath , $ fileName ) ; $ Spare -> imagePath = $ fileName ; } $ Spare -> save ( ) ; \ Session :: flash ( 'flash_message' , 'Added new Spare.' ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//<--FLASH MESSAGE