app/Http/Controllers/SupplierController.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 ('name' => 'required',
						'contactPerson' => 'required',
						'telephone' => 'required|numeric',
						'address' => 'required',
						);
		$messages = ['name.required' => 'Please input the supplier name',
					 'contactPerson.required' => 'Please input the supplier contact Person',
					 'telephone.required' => 'Please input the telephone number',
					 'telephone.numeric' => 'Please input the telephone number in correct format',
					 'address.required' => 'Please input the address in correct format',
					];
		$validator = Validator::make($input, $rules, $messages);
		if($validator->fails()) {
			return Redirect::to('supplier/create')->withErrors($validator);
		}else if(self::checkSupplierExist($request->name)){
				return back()->withErrors('Supplier Exist');
		}
			else {
			$supplier = new Supplier;
			$supplier->name = $request->name;
			$supplier->contactPerson = $request->contactPerson;
			$supplier->telephone = $request->telephone;
			$supplier->address = $request->address;
			$supplier->status = 'Active';
			$supplier->save();
			return redirect('supplier')->with('success','Apply Supplier Information Successfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'name' => 'required' , 'contactPerson' => 'required' , 'telephone' => 'required|numeric' , 'address' => 'required' , ) ; $ messages = [ 'name.required' => 'Please input the supplier name' , 'contactPerson.required' => 'Please input the supplier contact Person' , 'telephone.required' => 'Please input the telephone number' , 'telephone.numeric' => 'Please input the telephone number in correct format' , 'address.required' => 'Please input the address in correct format' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ messages ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'supplier/create' ) -> withErrors ( $ validator ) ; } else if ( self :: checkSupplierExist ( $ request -> name ) ) { return back ( ) -> withErrors ( 'Supplier Exist' ) ; } else { $ supplier = new Supplier ; $ supplier -> name = $ request -> name ; $ supplier -> contactPerson = $ request -> contactPerson ; $ supplier -> telephone = $ request -> telephone ; $ supplier -> address = $ request -> address ; $ supplier -> status = 'Active' ; $ supplier -> save ( ) ; return redirect ( 'supplier' ) -> with ( 'success' , 'Apply Supplier Information Successfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .