app/Http/Controllers/AgreementLineController.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)
    {
        $input = $request->all();
		$rules = array ('agreementID' => 'required|numeric',
						'revision' => 'required|numeric',
						'itemID' => 'required|numeric',
						'price' => 'required|numeric',);
		$message = ['agreementID.required' => 'Please input the agreement id',
					'agreementID.numeric' => 'Please input the agreement id in correct format',
					'revision.required' => 'Please input the revision',
					'revision.numeric' => 'Please input the revision in correct format',
					'itemID.required' => 'Please input the item id',
					'itemID.numeric' => 'Please input the item id in correct format',
					'price.required' => 'Please input the price',
					'price.numeric' => 'Please input the price in correct format',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('agreementLine/create')->withErrors($validator);
		} 
		else if (validateInput($request))
		{
			return Redirect::to('agreementLine/create')->withErrors('The Agreement ID does not exist in AgreementLine Table !');
		}
		else 
		{
			$agreementLine = new AgreementLine;
			$agreementLine->agreementID = $request->agreementLineID;
			$agreementLine->revision = $request->revision;
			$agreementLine->itemID = $request->itemID;
			$agreementLine->promisedQuantity = $request->promisedQuantity;
			$agreementLine->minimumOrderQuantity = $request->minimumOrderQuantity;
			$agreementLine->price = $request->price;
			$agreementLine->reference = $request->reference;
			$agreementLine->save();
			return back()->with('Apply agreementLine Information','Store the AgreementLine Information Sucessfully!');
		}
        $agreementID = $request->input('agreementID', []);
        $revision = $request->input('revision', []);
        $itemID = $request->input('itemID', []);
        $promisedQuantity = $request->input('promisedQuantity', []);
        $minimumOrderQuantity = $request->input('minimumOrderQuantity', []);
        $price = $request->input('price', []);
        $reference= $request->input('reference', []);
        for ($item=0; $item < count($descs); $item++) {
            $agreementLine = new AgreementLine;
            if ($agreementID[$item] != '') {
        		$agreementLine->agreementID = $agreementID[$item];
        		$agreementLine->revision = $revision[$item];
        		$agreementLine->itemID = $itemID[$item];
        		$agreementLine->promisedQuantity = $promisedQuantity[$item];
        		$agreementLine->minimumOrderQuantity = $minimumOrderQuantity[$item];
        		$agreementLine->price = $price[$item];
        		$agreementLine->reference = $reference[$item];
                $agreementLine->save($agreementLine);
        	}
        }
	}
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'agreementID' => 'required|numeric' , 'revision' => 'required|numeric' , 'itemID' => 'required|numeric' , 'price' => 'required|numeric' , ) ; $ message = [ 'agreementID.required' => 'Please input the agreement id' , 'agreementID.numeric' => 'Please input the agreement id in correct format' , 'revision.required' => 'Please input the revision' , 'revision.numeric' => 'Please input the revision in correct format' , 'itemID.required' => 'Please input the item id' , 'itemID.numeric' => 'Please input the item id in correct format' , 'price.required' => 'Please input the price' , 'price.numeric' => 'Please input the price in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'agreementLine/create' ) -> withErrors ( $ validator ) ; } else if ( validateInput ( $ request ) ) { return Redirect :: to ( 'agreementLine/create' ) -> withErrors ( 'The Agreement ID does not exist in AgreementLine Table !' ) ; } else { $ agreementLine = new AgreementLine ; $ agreementLine -> agreementID = $ request -> agreementLineID ; $ agreementLine -> revision = $ request -> revision ; $ agreementLine -> itemID = $ request -> itemID ; $ agreementLine -> promisedQuantity = $ request -> promisedQuantity ; $ agreementLine -> minimumOrderQuantity = $ request -> minimumOrderQuantity ; $ agreementLine -> price = $ request -> price ; $ agreementLine -> reference = $ request -> reference ; $ agreementLine -> save ( ) ; return back ( ) -> with ( 'Apply agreementLine Information' , 'Store the AgreementLine Information Sucessfully!' ) ; } $ agreementID = $ request -> input ( 'agreementID' , [ ] ) ; $ revision = $ request -> input ( 'revision' , [ ] ) ; $ itemID = $ request -> input ( 'itemID' , [ ] ) ; $ promisedQuantity = $ request -> input ( 'promisedQuantity' , [ ] ) ; $ minimumOrderQuantity = $ request -> input ( 'minimumOrderQuantity' , [ ] ) ; $ price = $ request -> input ( 'price' , [ ] ) ; $ reference = $ request -> input ( 'reference' , [ ] ) ; for ( $ item = 0 ; $ item < count ( $ descs ) ; $ item ++ ) { $ agreementLine = new AgreementLine ; if ( $ agreementID [ $ item ] != '' ) { $ agreementLine -> agreementID = $ agreementID [ $ item ] ; $ agreementLine -> revision = $ revision [ $ item ] ; $ agreementLine -> itemID = $ itemID [ $ item ] ; $ agreementLine -> promisedQuantity = $ promisedQuantity [ $ item ] ; $ agreementLine -> minimumOrderQuantity = $ minimumOrderQuantity [ $ item ] ; $ agreementLine -> price = $ price [ $ item ] ; $ agreementLine -> reference = $ reference [ $ item ] ; $ agreementLine -> save ( $ agreementLine ) ; } } }
Store a newly created resource in storage.
Store a newly created resource in storage .