app/Http/Controllers/PurchaseRequestController.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 ('requestID' => 'required|numeric',
						'branchID' => 'required|numeric',
						'createdDate' => 'required',
						'expectedDeliveryDate' => 'required',
						'status' => 'required',);
		$message = ['requestID.required' => 'Please input the request ID',
					'requestID.numeric' => 'Please input the request ID in correct format',
					'branchID.required' => 'Please input the branch id',
					'branchID.numeric' => 'Please input the branch id in correct format',
					'createdDate.required' => 'Please input the created date',
					'expectedDeliveryDate.required' => 'Please input the expected delivery date',
					'status.required' => 'Please input the status',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('purchaseRequest/create')->withErrors($validator);
		} 
		else if (!foreignKeyExists($request))
		{
			return Redirect::to('purchaseRequest/create')->withErrors('The Purchase Request does not exist in Purchase Request Table!');
		}
		else 
		{
			$purchaseRequest = new PurchaseRequest;
			$purchaseRequest->branchID = $request->branchID;
			$purchaseRequest->createdDate = $request->createdDate;
			$purchaseRequest->expectedDeliveryDate = $request->expectedDeliveryDate;
			$purchaseRequest->status = $request->status;
			if($request->remarks == null) {
				$purchaseRequest->remarks = "";
			}else {
				$purchaseRequest->remarks = $request->remarks;
			}
			$purchaseRequest->save();
			return back()->with('Apply purchaseRequest Information', 'Apply Purchase Request Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'requestID' => 'required|numeric' , 'branchID' => 'required|numeric' , 'createdDate' => 'required' , 'expectedDeliveryDate' => 'required' , 'status' => 'required' , ) ; $ message = [ 'requestID.required' => 'Please input the request ID' , 'requestID.numeric' => 'Please input the request ID in correct format' , 'branchID.required' => 'Please input the branch id' , 'branchID.numeric' => 'Please input the branch id in correct format' , 'createdDate.required' => 'Please input the created date' , 'expectedDeliveryDate.required' => 'Please input the expected delivery date' , 'status.required' => 'Please input the status' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'purchaseRequest/create' ) -> withErrors ( $ validator ) ; } else if ( ! foreignKeyExists ( $ request ) ) { return Redirect :: to ( 'purchaseRequest/create' ) -> withErrors ( 'The Purchase Request does not exist in Purchase Request Table!' ) ; } else { $ purchaseRequest = new PurchaseRequest ; $ purchaseRequest -> branchID = $ request -> branchID ; $ purchaseRequest -> createdDate = $ request -> createdDate ; $ purchaseRequest -> expectedDeliveryDate = $ request -> expectedDeliveryDate ; $ purchaseRequest -> status = $ request -> status ; if ( $ request -> remarks == null ) { $ purchaseRequest -> remarks = " " ; } else { $ purchaseRequest -> remarks = $ request -> remarks ; } $ purchaseRequest -> save ( ) ; return back ( ) -> with ( 'Apply purchaseRequest Information' , 'Apply Purchase Request Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .