app/Http/Controllers/DispatchInstructionItemController.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 ('diNo' => 'required|numeric',
						'itemID' => 'required|numeric',
						'quantity' => 'required|numeric',
						'balance' => 'required|numeric',);
		$message = ['diNo.required' => 'Please input the delivery instruction number',
					'diNo.numeric' => 'Please input the delivery instruction number in correct format',
					'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 in correct format',
					'balance.required' => 'Please input the balance',
					'balance.numeric' => 'Please input the balance in correct format',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('dispatchInstructionItem/create')->withErrors($validator);
		} 
		else if (!foreignKeyExists($request))
		{
			return Redirect::to('dispatchInstructionItem/create')->withErrors('The Purchase Order is not found in Pu Table !');
		}
		else 
		{
			$dispatchInstructionItem = new DispatchInstructionItem;
			$dispatchInstructionItem->diNo = $request->diNo;
			$dispatchInstructionItem->itemID = $request->itemID;
			$dispatchInstructionItem->quantity = $request->quantity;
			$dispatchInstructionItem->balance = $request->balance;
			$dispatchInstructionItem->save();
			return back()->with('Apply dispatchInstructionItem Information','Apply Dispatch Instruction Item Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'diNo' => 'required|numeric' , 'itemID' => 'required|numeric' , 'quantity' => 'required|numeric' , 'balance' => 'required|numeric' , ) ; $ message = [ 'diNo.required' => 'Please input the delivery instruction number' , 'diNo.numeric' => 'Please input the delivery instruction number in correct format' , '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 in correct format' , 'balance.required' => 'Please input the balance' , 'balance.numeric' => 'Please input the balance in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'dispatchInstructionItem/create' ) -> withErrors ( $ validator ) ; } else if ( ! foreignKeyExists ( $ request ) ) { return Redirect :: to ( 'dispatchInstructionItem/create' ) -> withErrors ( 'The Purchase Order is not found in Pu Table !' ) ; } else { $ dispatchInstructionItem = new DispatchInstructionItem ; $ dispatchInstructionItem -> diNo = $ request -> diNo ; $ dispatchInstructionItem -> itemID = $ request -> itemID ; $ dispatchInstructionItem -> quantity = $ request -> quantity ; $ dispatchInstructionItem -> balance = $ request -> balance ; $ dispatchInstructionItem -> save ( ) ; return back ( ) -> with ( 'Apply dispatchInstructionItem Information' , 'Apply Dispatch Instruction Item Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .