I have tried to help myself using the similar threads that share the same topic but it did not yield the desired result. I'm yet to understand what needed to be fixed in the code making it to generate the error. Please kindly help out. What is to be put right? Thanks. Appreciate.
This is the code:
public function store(Request $request){
$validator = Validator::make($request->all(), [
'user_id' => 'required|numeric',
'company_id' => 'required|numeric',
'product_id' => 'required|numeric',
'tankerTotankerDesc' => 'alpha_num|min:5',
'tankerTakeOverDesc' => 'alpha_num|min:5',
'costFreightInsuranceDesc' => 'alpha_num|min:5',
'freightOnBoardDesc' => 'alpha_num|min:5',
'tankerTotankerPrice' => 'numeric|required_with:tankerTotankerDesc',
'tankerTakeOverPrice' => 'numeric|required_with:tankerTakeOverDesc',
'costFreightInsurancePrice' => 'numeric|required_with:costFreightInsuranceDesc',
'freightOnBoardPrice' => 'numeric|required_with:freightOnBoardDesc',
'optional_procedure' => 'alpha_num|min:5',
'optional_procedure_price' => 'numeric|required_with:optional_procedure',
'business_type' => 'required'
]);
if ($validator->fails()) {
redirect()->route('productUniqueCreate', $validator)->with('message', 'Record successfully created');
}else{
$product_id = $request->product_id;
$procurementUnique = ProcurementUnique::firstOrNew(array('product_id'=>$product_id));
$procurementUnique->user_id = $user_id;
$procurementUnique->company_id = $request->company_id;
$procurementUnique->product_id = $product_id;
$procurementUnique->productname = $request->productname;
$procurementUnique->ttt_description = $request->tankerTotankerDesc;
$procurementUnique->tto_description = $request->tankerTakeOverDesc;
$procurementUnique->cif_description = $request->costFreightInsuranceDesc;
$procurementUnique->fob_description = $request->freightOnBoardDesc;
$procurementUnique->optional_procedure = $request->optional_procedure;
$procurementUnique->ttt_price = $request->tankerTotankerPrice;
$procurementUnique->tto_price = $request->tankerTakeOverPrice;
$procurementUnique->cif_price = $request->costFreightInsurancePrice;
$procurementUnique->fob_price = $request->freightOnBoardPrice;
$procurementUnique->optional_procedure_price = $request->optional_procedure_price;
$procurementUnique->business_type = $request->business_type;
$procurementUnique->save();
return redirect()->route('productUniqueCreate', $product_id)->with('message', 'Record successfully created');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire