app/Http/Controllers/BranchItemController.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 ('branchID' => 'required|numeric',
						'itemID' => 'required|numeric',
						'quantity' => 'required|numeric',);
		$message = ['branchID.required' => 'Please input the branch id',
					'branchID.numeric' => 'Please input the branch id in correct format',
					'itemID.numeric' => 'Please input the item id in correct format',
					'itemID.required' => 'Please input the item id',
					'quantity.required' => 'Please input the quantity',
					'quantity.numeric' => 'Please input the quantity in correct format',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) {
			return Redirect::to('branchItem/create')->withErrors($validator);
		} else if (compositeKeyExists($request)) {
			return back()->withErrors('Failed to store the Branch Item as branchID and itemID is duplicated, you enter the unique composite key (branchID, itemID) !'); 
		} else {
			$branchItem = new BranchItem;
			$branchItem->branchID = $request->branchID;
			$branchItem->itemID = $request->itemID;
			$branchItem->quantity = $request->quantity;
			$branchItem->lowStockLevel = $request->lowStockLevel;
			$branchItem->save();
			return back()->with('Apply branch item Information','Apply branch item Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'branchID' => 'required|numeric' , 'itemID' => 'required|numeric' , 'quantity' => 'required|numeric' , ) ; $ message = [ 'branchID.required' => 'Please input the branch id' , 'branchID.numeric' => 'Please input the branch id in correct format' , 'itemID.numeric' => 'Please input the item id in correct format' , 'itemID.required' => 'Please input the item id' , 'quantity.required' => 'Please input the quantity' , 'quantity.numeric' => 'Please input the quantity in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'branchItem/create' ) -> withErrors ( $ validator ) ; } else if ( compositeKeyExists ( $ request ) ) { return back ( ) -> withErrors ( 'Failed to store the Branch Item as branchID and itemID is duplicated, you enter the unique composite key (branchID, itemID) !' ) ; } else { $ branchItem = new BranchItem ; $ branchItem -> branchID = $ request -> branchID ; $ branchItem -> itemID = $ request -> itemID ; $ branchItem -> quantity = $ request -> quantity ; $ branchItem -> lowStockLevel = $ request -> lowStockLevel ; $ branchItem -> save ( ) ; return back ( ) -> with ( 'Apply branch item Information' , 'Apply branch item Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .