app/Http/Controllers/BranchItemController.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(Request $request, $id)
    {
        $input = $request->all();
		$rules = array ('branchID' => 'required|numeric',
						'itemID' => 'required|numeric',
						'quantity' => 'required|numeric',);
		$message = ['branchID.required' => 'Please input the branch id',
					'branchID.nuermic' => 'Please input the branch id in correct format',
					'itemID.required' => 'Please input the telephone number',
					'itemID.numeric' => 'Please input the telephone number in correct format',
					'quantity.required' => 'Please input the quantity',
					'quantity.numeric' => 'Please input the quantity in correct format',];
        $validator = Validator::make($input, $rules, $messages);                 
        if ($validator->fails()) {             
            return Redirect::to('branchItem/create')->withErrors($validator);
        } else if (!compositeKeyExists($request)) {
            return back()->withErrors('Failed to update the Branch Item as branchID and itemID is not found !'); 
        } else {       
            $branchItem = BranchItem::where('branchID', $branchID)->where('itemID', $itemID)->get();         
			$branchItem->branchID = $request->branchID;
			$branchItem->itemID = $request->itemID;
			$branchItem->quantity = $request->quantity;
			$branchItem->lowStockLevel = $request->lowStockLevel;
            $branchItem->save();         
            return back()->with('success','Successfully updated branchItem Information!');     
        }   
    }
public function update ( Request $ request , $ id ) { $ input = $ request -> all ( ) ; $ rules = array ( 'branchID' => 'required|numeric' , 'itemID' => 'required|numeric' , 'quantity' => 'required|numeric' , ) ; $ message = [ 'branchID.required' => 'Please input the branch id' , 'branchID.nuermic' => 'Please input the branch id in correct format' , 'itemID.required' => 'Please input the telephone number' , 'itemID.numeric' => 'Please input the telephone number in correct format' , 'quantity.required' => 'Please input the quantity' , 'quantity.numeric' => 'Please input the quantity in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ messages ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'branchItem/create' ) -> withErrors ( $ validator ) ; } else if ( ! compositeKeyExists ( $ request ) ) { return back ( ) -> withErrors ( 'Failed to update the Branch Item as branchID and itemID is not found !' ) ; } else { $ branchItem = BranchItem :: where ( 'branchID' , $ branchID ) -> where ( 'itemID' , $ itemID ) -> get ( ) ; $ branchItem -> branchID = $ request -> branchID ; $ branchItem -> itemID = $ request -> itemID ; $ branchItem -> quantity = $ request -> quantity ; $ branchItem -> lowStockLevel = $ request -> lowStockLevel ; $ branchItem -> save ( ) ; return back ( ) -> with ( 'success' , 'Successfully updated branchItem Information!' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .