app/Http/Controllers/AgreementHeaderController.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',
						'supplierID' => 'required|numeric',
						'type' => 'required',
						'createdDate' => 'required|date',
						'effectiveDate' => 'required|date',
						'expiryDate' => 'required|date',
						'currency' => 'required',
						'termsAndCondition' => 'required',
						'deliveryAddress' => 'required',);
		$messages = ['agreementID.required' => 'Please input the agreement id',
					 'agreementID.numeric' => 'Please input the agreement id in correct format',
					 'revision.required' => 'Please input the revision no.',
					 'revision.numeric' => 'Please input the revision no. in correct format',
					 'supplierID.required' => 'Please input the supplier id',
					 'supplierID.numeric' => 'Please input the supplier id in correct format',
					 'type.required' => 'Please input the agreement type',
					 'createdDate.required' => 'Please input the created date',
					 'createdDate.date' => 'Please input the created date in correct date format',
					 'effectiveDate.required' => 'Please input the effective date',
					 'effectiveDate.date' => 'Please input the effective date in correct date format',
					 'expiryDate.required' => 'Please input the expiry date',
					 'expiryDate.date' => 'Please input the expiry date in correct date format',
					 'currency.required' => 'Please input the currency',
					 'termsAndCondition.required' => 'Please input the terms and condition',
					 'deliveryAddress.required' => 'Please input the delivery address'];
		$validator = Validator::make($input, $rules, $messages);
		if($validator->fails()) 
		{
			return Redirect::to('agreementHeader/create')->withErrors($validator);
		} 
		else 
		{
			$agreementHeader = new AgreementHeader;
			$agreementHeader->agreementID = $request->agreementID;
			$agreementHeader->revision = $request->revision;
			$agreementHeader->supplierID = $request->supplierID;
			$agreementHeader->type = $request->type;
			$agreementHeader->createdDate = $request->createdDate;
			$agreementHeader->effectiveDate = $request->effectiveDate;
			$agreementHeader->expiryDate = $request->expiryDate;
			if ((($request->effectiveDate <= date("Y-m-d")) && (date("Y-m-d") <= $request->expiryDate))){
				$temp = "Active";
			} else if ($request->expiryDate <= date("Y-m-d")){
				$temp = "Expired";
			} else if ($request->effectiveDate >= date("Y-m-d")){
				$temp = "Inactive";
			}
			$agreementHeader->status = $temp;
			$agreementHeader->amountAgreed = $request->amountAgreed;
			$agreementHeader->currency = $request->currency;
			$agreementHeader->termsAndCondition = $request->termsAndCondition;
			$agreementHeader->tentativeSchedule = $request->tentativeSchedule;
			$agreementHeader->deliveryAddress = $request->deliveryAddress;			
			$agreementHeader->save();
			return Redirect::to('agreementLine/create')->with('success','Apply agreementHeader Information Sucessfully'."\n".'Please input the agreement line');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'agreementID' => 'required|numeric' , 'revision' => 'required|numeric' , 'supplierID' => 'required|numeric' , 'type' => 'required' , 'createdDate' => 'required|date' , 'effectiveDate' => 'required|date' , 'expiryDate' => 'required|date' , 'currency' => 'required' , 'termsAndCondition' => 'required' , 'deliveryAddress' => 'required' , ) ; $ messages = [ 'agreementID.required' => 'Please input the agreement id' , 'agreementID.numeric' => 'Please input the agreement id in correct format' , 'revision.required' => 'Please input the revision no.' , 'revision.numeric' => 'Please input the revision no. in correct format' , 'supplierID.required' => 'Please input the supplier id' , 'supplierID.numeric' => 'Please input the supplier id in correct format' , 'type.required' => 'Please input the agreement type' , 'createdDate.required' => 'Please input the created date' , 'createdDate.date' => 'Please input the created date in correct date format' , 'effectiveDate.required' => 'Please input the effective date' , 'effectiveDate.date' => 'Please input the effective date in correct date format' , 'expiryDate.required' => 'Please input the expiry date' , 'expiryDate.date' => 'Please input the expiry date in correct date format' , 'currency.required' => 'Please input the currency' , 'termsAndCondition.required' => 'Please input the terms and condition' , 'deliveryAddress.required' => 'Please input the delivery address' ] ; $ validator = Validator :: make ( $ input , $ rules , $ messages ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'agreementHeader/create' ) -> withErrors ( $ validator ) ; } else { $ agreementHeader = new AgreementHeader ; $ agreementHeader -> agreementID = $ request -> agreementID ; $ agreementHeader -> revision = $ request -> revision ; $ agreementHeader -> supplierID = $ request -> supplierID ; $ agreementHeader -> type = $ request -> type ; $ agreementHeader -> createdDate = $ request -> createdDate ; $ agreementHeader -> effectiveDate = $ request -> effectiveDate ; $ agreementHeader -> expiryDate = $ request -> expiryDate ; if ( ( ( $ request -> effectiveDate <= date ( " Y-m-d " ) ) && ( date ( " Y-m-d " ) <= $ request -> expiryDate ) ) ) { $ temp = " Active " ; } else if ( $ request -> expiryDate <= date ( " Y-m-d " ) ) { $ temp = " Expired " ; } else if ( $ request -> effectiveDate >= date ( " Y-m-d " ) ) { $ temp = " Inactive " ; } $ agreementHeader -> status = $ temp ; $ agreementHeader -> amountAgreed = $ request -> amountAgreed ; $ agreementHeader -> currency = $ request -> currency ; $ agreementHeader -> termsAndCondition = $ request -> termsAndCondition ; $ agreementHeader -> tentativeSchedule = $ request -> tentativeSchedule ; $ agreementHeader -> deliveryAddress = $ request -> deliveryAddress ; $ agreementHeader -> save ( ) ; return Redirect :: to ( 'agreementLine/create' ) -> with ( 'success' , 'Apply agreementHeader Information Sucessfully' . " \n " . 'Please input the agreement line' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .