app/Http/Controllers/DispatchInstructionController.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',
						'createdDate' => 'required',
						'status' => 'required',);
		$message = ['requestID.required' => 'Please input the request id',
					'requestID.numeric' => 'Please input the request id in correct format',
					'createdDate.required' => 'Please input the created date',
					'status.required' => 'Please input the status in correct format',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('dispatchInstruction/create')->withErrors($validator);
		} 
		else if (!foreignKeyExists($request))
		{
			return Redirect::to('dispatchInstruction/create')->withErrors('The Purchase Order is not found in Pu Table !');
		}
		else 
		{
			$dispatchInstruction = new DispatchInstruction;
			$dispatchInstruction->requestID = $request->branchID;
			$dispatchInstruction->createdDate = $request->createdDate;
			$dispatchInstruction->status = $request->status;
			$dispatchInstruction->save();
			return back()->with('Apply dispatchInstruction Information','Apply Dispatch Instruction Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'requestID' => 'required|numeric' , 'createdDate' => 'required' , 'status' => 'required' , ) ; $ message = [ 'requestID.required' => 'Please input the request id' , 'requestID.numeric' => 'Please input the request id in correct format' , 'createdDate.required' => 'Please input the created date' , 'status.required' => 'Please input the status in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'dispatchInstruction/create' ) -> withErrors ( $ validator ) ; } else if ( ! foreignKeyExists ( $ request ) ) { return Redirect :: to ( 'dispatchInstruction/create' ) -> withErrors ( 'The Purchase Order is not found in Pu Table !' ) ; } else { $ dispatchInstruction = new DispatchInstruction ; $ dispatchInstruction -> requestID = $ request -> branchID ; $ dispatchInstruction -> createdDate = $ request -> createdDate ; $ dispatchInstruction -> status = $ request -> status ; $ dispatchInstruction -> save ( ) ; return back ( ) -> with ( 'Apply dispatchInstruction Information' , 'Apply Dispatch Instruction Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .