app/Http/Controllers/PurchaseRequestItemController.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',
						'itemID' => 'required|numeric',
						'quantity' => 'required|numeric',
						'balance' => 'required|numeric',);
		$message = ['itemID.required' => 'Please input the item id',
					'itemID.numeric' => 'Please input the item id in correct format',
					'quantity.required' => 'Please input the quantity',
					'quantity.numeric' => 'Please input the quantity',
					'balance.required' => 'Please input the balance in correct format',
					'balance.numeric' => 'Please input the balance',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('purchaseRequestItem/create')->withErrors($validator);
		} 
		else if (!$this->foreignKeyExists($request))
		{
			return Redirect::to('purchaseRequestItem/create')->withErrors('The Purchase Request Item does not exist in other tables!');
		}
		else 
		{
			$purchaseRequestItem = new PurchaseRequestItem;
			$purchaseRequestItem->itemID = $request->itemID;
			$purchaseRequestItem->quantity = $request->quantity;
			$purchaseRequestItem->balance = $request->balance;
			$purchaseRequestItem->remarks = $request->remarks;
			$purchaseRequestItem->save();
			return back()->with('Apply Purchase Request Item Information','Apply Purchase Request Item Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'requestID' => 'required|numeric' , 'itemID' => 'required|numeric' , 'quantity' => 'required|numeric' , 'balance' => 'required|numeric' , ) ; $ message = [ 'itemID.required' => 'Please input the item id' , 'itemID.numeric' => 'Please input the item id in correct format' , 'quantity.required' => 'Please input the quantity' , 'quantity.numeric' => 'Please input the quantity' , 'balance.required' => 'Please input the balance in correct format' , 'balance.numeric' => 'Please input the balance' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'purchaseRequestItem/create' ) -> withErrors ( $ validator ) ; } else if ( ! $ this -> foreignKeyExists ( $ request ) ) { return Redirect :: to ( 'purchaseRequestItem/create' ) -> withErrors ( 'The Purchase Request Item does not exist in other tables!' ) ; } else { $ purchaseRequestItem = new PurchaseRequestItem ; $ purchaseRequestItem -> itemID = $ request -> itemID ; $ purchaseRequestItem -> quantity = $ request -> quantity ; $ purchaseRequestItem -> balance = $ request -> balance ; $ purchaseRequestItem -> remarks = $ request -> remarks ; $ purchaseRequestItem -> save ( ) ; return back ( ) -> with ( 'Apply Purchase Request Item Information' , 'Apply Purchase Request Item Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .