app/Http/Controllers/DeliveryNoteController.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 ('dnNo' => 'required|numeric',
						'diNo' => 'required|numeric',
						);
		$message = ['dnNo.required' => 'Please input the delivery note number',
					'dnNo.numeric' => 'Please input the delivery note number in correct format',
					'diNo.required' => 'Please input the dispatch instruction number',
					'diNo.numeric' => 'Please input the dispatch instruction in correct format',
					];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) 
		{
			return Redirect::to('deliveryNote/create')->withErrors($validator);
		} else if(DeliveryNote::where('dnNo',$request->dnNo)->exists()){
			return Redirect::to('deliveryNote/')->withErrors('Fail to Created');
		}else if(DeliveryNote::where('diNo',$request->diNo)->exists()){
			return Redirect::to('deliveryNote/')->withErrors('Fail to Created');
		}
		else 
		{
			$deliveryNote = new DeliveryNote;
			$deliveryNote->dnNo = $request->dnNo;
			$deliveryNote->diNo = $request->diNo;
			$deliveryNote->createdDate = \Carbon\Carbon::now()->format('Y-m-d');
			$deliveryNote->status ='Pending for Delivery';
			$deliveryNote->save();
			return  Redirect::to('deliveryNote/')->with('success','Apply Delivery Note Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'dnNo' => 'required|numeric' , 'diNo' => 'required|numeric' , ) ; $ message = [ 'dnNo.required' => 'Please input the delivery note number' , 'dnNo.numeric' => 'Please input the delivery note number in correct format' , 'diNo.required' => 'Please input the dispatch instruction number' , 'diNo.numeric' => 'Please input the dispatch instruction in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'deliveryNote/create' ) -> withErrors ( $ validator ) ; } else if ( DeliveryNote :: where ( 'dnNo' , $ request -> dnNo ) -> exists ( ) ) { return Redirect :: to ( 'deliveryNote/' ) -> withErrors ( 'Fail to Created' ) ; } else if ( DeliveryNote :: where ( 'diNo' , $ request -> diNo ) -> exists ( ) ) { return Redirect :: to ( 'deliveryNote/' ) -> withErrors ( 'Fail to Created' ) ; } else { $ deliveryNote = new DeliveryNote ; $ deliveryNote -> dnNo = $ request -> dnNo ; $ deliveryNote -> diNo = $ request -> diNo ; $ deliveryNote -> createdDate = \ Carbon \ Carbon :: now ( ) -> format ( 'Y-m-d' ) ; $ deliveryNote -> status = 'Pending for Delivery' ; $ deliveryNote -> save ( ) ; return Redirect :: to ( 'deliveryNote/' ) -> with ( 'success' , 'Apply Delivery Note Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .