I have an issue when update a form in Spring boot - spring

I want to update a form in spring boot - all input fields are successfully populated from the retrieved data but when I press 'submit' for update the system gives this error message.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Nov 07 09:41:44 IST 2017
There was an unexpected error (type=Internal Server Error, status=500).
For input string: "updateApplication"
My DAO code:
public interface SLSNotificationRepository extends CrudRepository<SLSNotification, Integer> {
#Override
SLSNotification save(SLSNotification slsNotification);
#Override
SLSNotification findOne(Integer integer);
#Override
long count();
#Override
void delete(Integer integer);
#Override
void delete(SLSNotification slsNotification);
#Override
void delete(Iterable<? extends SLSNotification> iterable);
#Override
List<SLSNotification> findAll();
#Query("select a from SLSNotification a where a.slsiUnit in :unitList")
List<SLSNotification> getApplicationsByUnit(#Param("unitList")List <String> unitList);
#Query("select a from SLSNotification a where a.userId = :userId")
List<SLSNotification> getApplicationsByUserId(#Param("userId")String userId);
#Query("select a from SLSNotification a where a.slsNo = :slsNo")
SLSNotification getApplicationBySLSNumber(#Param("slsNo") String slsNo);
#Query("select a from SLSNotification a where a.importerVAT = :importerVAT group by slsNo")
List<SLSNotification> getproductByUserId(#Param("importerVAT")String importerVAT);
}
My service:
public boolean update(SLSNotification slsNotification) {
serviceLogger.info("Staring adding/updating the SLS Notification data . data : [{}]", slsNotification);
try {
serviceLogger.info("Saving data in the database. [{}]", slsNotification);
slsNotificationRepository.save(slsNotification);
return true;
} catch (Exception e) {
serviceLogger.error("Error occurred while saving SLS Common data . [{}]", e);
rollBack.rollback();
return false;
}
}
My controller is
#RequestMapping(path = "/updateApplication", method = RequestMethod.POST)
public String updateApplication(#ModelAttribute("applicationForm") #Valid SLSNotification slsNotification,
BindingResult result,
HttpSession session) {
slsiLogger.info("Request received to register new product. [{}]", slsNotification);
if (result.hasErrors()) {
slsiLogger.error("Rejecting the request due to binding errors, [{}]", result.getFieldErrors());
return "redirect:/applicationManage?";
}
if (applicationServices.update(slsNotification)) {
slsiLogger.info("Product registered successfully");
session.setAttribute(MESSAGE_KEY, "Product registered successfully");
} else {
session.setAttribute(MESSAGE_KEY, "Error occurred while registering the product");
}
return "redirect:/applicationManage?" + MESSAGE_KEY;
}
My JSP:
<form:form name="applicationForm" id="applicationForm" action="updateApplication" commandName="app" method="post">
<c:if test="${edit}">
<input type="hidden" id="snumber" name="snumber" value="${app.snumber}"/>
</c:if>
<div class="panel panel-default">
<div class="panel-body" >
<div class="row">
<label id="aaa" for="manufacturer" class="col-sm-2 col-form-label col-form-label-lg">Manufacturer Name &
Address <div class="req" > *</div></label>
<label id="bbb" for="manufacturer" class="col-sm-2 col-form-label col-form-label-lg">Manufacturer Name <div class="req" > *</div></label>
<div id="">
<div class="col-sm-4">
<div class="checkbox">
<label><input type="checkbox" value="" id="registered">Registered Manufacturer in SLSI</label>
</div>
<div id="regManu">
<select id="companies">
<c:forEach items="${manu}" var="com">
<option value="${com.manufacturerName}">${com.manufacturerName}</option>
</c:forEach>
</select>
</div>
<textarea name="manufacturer" class="form-control form-control-lg"
id="manufacturer"
placeholder="Enter the name & Address. Press Enter at the end of each line"
aria-descrribedby="exportertHelp" data-error="Name & Address is required!"
required rows="4" maxlength="254"></textarea>
<input type="hidden" id="manufacture" name="manufacture" value="${app.manufacturer}"/>
<div class="help-block with-errors"></div>
</div>
<label for="exporterAddress" class="col-sm-2 col-form-label col-form-label-lg">Exporter Name &
Address <div class="req"> *</div></label>
<div class="col-sm-4">
<textarea name="exporterAddress" class="form-control form-control-lg" id="exporterAddress"
placeholder="Enter the name & Address. Press Enter at the end of each line"
aria-descrribedby="exportertHelp" data-error="Name & Address is required!"
required rows="5" maxlength="254"></textarea><br/><br/>
<input type="hidden" id="exp" name="exp" value="${app.exporterAddress}"/>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<br/> <label for="importerVAT" class="col-sm-2 col-form-label col-form-label-lg">Importer VAT <div class="req"> *</div></label>
<div class="col-sm-4">
<input class="form-control" type="text" name="importerVAT" id="importerVAT"
aria-describedby="importerVATHelp" placeholder="Ex : 174625588-7000 (White spaces not allowed)"
data-error="VAT number is required!" onkeyup="lettersOnly(this)" required value="${app.importerVAT}">
<div class="help-block with-errors"></div>
</div>
<label for="declarantVAT" class="col-sm-2 col-form-label col-form-label-lg">Declarant VAT <div class="req"> *</div></label>
<div class="col-sm-4">
<input class="form-control" name="declarantVAT" type="text" id="declarantVAT"
aria-describedby="declarantVATHelp" placeholder="Ex : 174625588-7000 (White spaces not allowed)"
data-error="VAT number is required!" onkeyup="lettersOnly(this)" required value="${app.declarantVAT}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row" >
<label for="importerDetails" class="col-sm-2 col-form-label col-form-label-lg">Importer Name &
Address <div class="req"> *</div></label>
<div class="col-sm-4">
<textarea name="importerDetails" class="form-control form-control-lg" id="importerDetails"
placeholder="Enter the name & Address. Press Enter at the end of each line"
aria-descrribedby="exportertHelp" data-error="Name and Address is required!"
required rows="4" maxlength="254"></textarea>
<input type="hidden" id="imp" name="imp" value="${app.importerDetails}"/>
<div class="help-block with-errors"></div>
</div>
<label for="declarantDetails" class="col-sm-2 col-form-label col-form-label-lg">Declarant Name &
Address <div class="req"> *</div></label>
</div>
</div>
<div class="form-group row">
<label for="cusOffice" class="col-sm-2 col-form-label col-form-label-lg">CusDec No &
Date</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="cusOffice " id="cusOffice " style="float:left;"
aria-describedby="importerVATHelp" placeholder=" Ex : KTIM1" value="${app.cusOffice}">
</div>
</div>
</div>
<div class="tabbable">
<br/>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-pills">
<li class="active"><a href="#tab1" data-toggle="pill" style="text-decoration: none;">Product
Details</a></li>
<li>Consignment Details</li>
<li>Attachments</li>
</ul>
<br/>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<div class="form-group row">
<label for="slsNo" class="col-sm-5 col-lg-2 col-xs-12 col-form-label col-form-label-lg">Relevant
SLS Standard No <div class="req"> *</div></label>
<div class="col-sm-3 col-sm-4">
<input class="form-control" type="text" id="slsNo" name="slsNo"
aria-describedby="slsNoHelp"
placeholder=" Enter SLS No here"
data-error="SLSI Standard No is required!" onkeyup="numbersOnly(this)" required value="${app.slsNo}">
<div class="help-block with-errors"></div>
</div>
<label for="slsiUnit" class="col-sm-1 col-form-label col-form-label-lg">
SLSI Unit <div class="req"> *</div></label>
<div class="col-sm-2">
<select class="form-control" id="slsiUnit" name="slsiUnit"
data-error="SLSI Unit is required!" required>
<option>UNIT1</option>
<option>UNIT2</option>
<option>UNIT3</option>
<option>UNIT4</option>
<option>UNIT5</option>
<option>UNIT6</option>
</select>
<input type="hidden" id="ut" name="ut" value="${app.slsiUnit}"/>
</div>
<label for="invoiceValue" class="col-sm-5 col-xs-6 col-md-5 col-lg-2 col-form-label col-form-label-lg">Invoice
Value (FOB) of the Product in US$ <div class="req"> *</div></label>
<div class="col-sm-6 col-md-3 col-lg-2 col-xs-6">
<div class="input-group">
<span class="input-group-addon">US$</span>
<input class="form-control" type="text" name="invoiceValue" id="invoiceValue"
aria-describedby="invoiceValueHelp"
placeholder="Value"
data-error="Invoice Value is required!" onkeyup="numbersOnly(this)" required value="${app.invoiceValue}"/>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group row">
<label for="invoiceValue" class="col-sm-4 col-xs-6 col-md-2 col-lg-2 ">Total
Quantity <div class="req"> *</div></label>
<div class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
<input class="form-control" type="text" name="totalQty" id="totalQty"
aria-describedby="totQtyHelp"
placeholder="Total Net Weight in Number"
data-error="Total Net Weight is required!" onkeyup="numbersOnly(this)" required value="${app.totalQty}">
</div>
<div class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
<select class="form-control" id="uom" name="uom" style="float:left;">
<option>KGM</option>
<option>UNITS</option>
<option>LITERS</option>
<option>CANS</option>
</select>
<input type="hidden" id="um" name="um" value="${app.uom}"/>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-md-4">
<div class="form-group">
<label for="shippingMarks" class="col-sm-12 col-form-label col-form-label-lg">Shipping
Marks & Container No/s </label>
<textarea name="marksNumber" class="form-control form-control-lg"
id="marksNumber" placeholder="If no of containers greater than 10 please attach the container numbers as an attachment"
data-error="Shipping marks are required!" maxlength="250" rows="5" ></textarea>
<input type="hidden" id="shims" name="shims" value="${app.marksNumber}"/>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-4 col-md-4">
<div class="form-group">
<label for="productDesc" class="col-sm-12 col-form-label col-form-label-lg">Product
Description (Max 250 charactors) <div class="req"> *</div></label>
<textarea value="${app.productDesc}" name="productDesc" class="form-control form-control-lg"
id="productDesc"
placeholder="Enter Product Description with brand,model/Type,size/s, quantity, Pkg.Type etc. here"
data-error="Product Description is required!" maxlength="250" required rows="5" ></textarea>
<input type="hidden" id="product" name="product" value="${app.productDesc}"/>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-4 col-md-4">
<div class="form-group">
<label for="purpose"
class="col-sm-12 col-form-label col-form-label-lg">Purpose <div class="req"> *</div></label>
<select class="form-control" id="purpose" name="purpose"
data-error="Purpose is required!" required>
<option>Commercial</option>
<option>Personal</option>
<option>Project</option>
<option>Charity</option>
<option>Further Processing</option>
</select>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="hsCode" class="col-sm-12 col-form-label col-form-label-lg">HS
Code <div class="req"> *</div></label>
<input class="form-control" type="text" id="hsCode" name="hsCode"
aria-describedby="hsCodHelp" placeholder=" Please enter HS Code here"
data-error="HS Code is required!" required value="${app.hsCode}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label for="issuerQltyCert" class="col-sm-12 col-form-label col-form-label-lg">Issuer
of Product/Quality Certificate <div class="req"> *</div></label>
<input class="form-control" type="text" id="issuerQltyCert" name="issuerQltyCert"
aria-describedby="issuerCertHelp"
placeholder=" Enter the Organization Issued the Certificate"
data-error="Organization is required!" required maxlength="254" value="${app.issuerQltyCert}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="certRefNo" class="col-sm-12 col-form-label col-form-label-lg">Product
Certificate Ref.No <div class="req"> *</div></label>
<input class="form-control" type="text" id="certRefNo" name="certRefNo"
aria-describedby="certRefNoHelp"
placeholder=" Please enter product certificate No."
data-error="Product certificate No is required!" required value="${app.certRefNo}" >
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab2">
<div class="form-group row">
<label for="vessel" class="col-sm-3 col-md-2 col-xs-7 col-form-label col-form-label-lg">Vessel
Name <div class="req"> *</div></label>
<div class="col-md-2">
<input class="form-control" type="text" name="vessel" id="vessel"
aria-describedby="vesselHelp" placeholder=" Vessel Name"
data-error="Vessel Name & Date is required!" required maxlength="254" value="${app.vessel}" >
</div>
<label for="blNo" class="col-sm-5 col-md-2 col-xs-6 col-lg-2 col-form-label col-form-label-lg">Bill Of Lading
No <div class="req"> *</div></label>
<label for="blNo" class="col-sm-12 col-md-2 col-xs-12 col-form-label col-form-label-lg">Date of B/L <div class="req"> *</div></label>
<div class="col-sm-1">
<input type="text" class="datep" format="YYYY-MM-dd" style="float:left;"
readonly='true' name="blDate" id="blDate">
</div>
</div>
<input class="form-control" type="text" name="loadingPort" id="loadingPort"
aria-describedby="loadPortHelp"
placeholder=" Please enter Port of Loading here"
data-error="Port of Loading is required!" required value="${app.loadingPort}">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" id="submit" class="btn btn-success pull-right">SAVE CHANGES</button>
</div>
</div>
</form:form>
How do I get the form update to work?

Related

Method Illuminate\Database\Eloquent\Collection::save does not exist

i have a problem when updating the database
error: Method Illuminate\Database\Eloquent\Collection::save does not exist.
controller:
public function actualizar(Request $request){
$nuevoIngreso = \App\Models\Servicio::all();
$nuevoIngreso->costo = $request->costo;
$nuevoIngreso->duracion = $request->duracion;
$nuevoIngreso->mantenimiento = $request->mantenimiento;
$nuevoIngreso->save();
return redirect('servicios')->with('mensaje', 'Ficha Actualizada.');
}
blade.php
<form method="POST" action="{{ route('actualizar') }}">
{{method_field('PUT')}}
#csrf
#foreach ($servicios as $costo)
<h1 class="text-center text-primary"> {{$costo->tipo}} </h1>
<div class="form-group row">
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Costo</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->costo}}">
</div>
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Duración</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->duracion}}" id="example-text-input">
</div>
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Mantenimiento</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->mantenimiento}}" id="example-text-input">
</div>
</div>
<hr>
#endforeach
<button type="submit" class="btn btn-success float-right" float-rightdata-toggle="sweet-alert" data-sweet-alert="success">SAVE</button>
</form>
help please
Error is clear.you are calling static method all().So it should be
$nuevoIngreso =new \App\Models\Servicio();
$nuevoIngreso->costo = $request->costo;
$nuevoIngreso->duracion = $request->duracion;
$nuevoIngreso->mantenimiento = $request->mantenimiento;
$nuevoIngreso->save();
So if you are thinking to update particular record then find by id or any column
$nuevoIngreso =new \App\Models\Servicio::find($id);
$nuevoIngreso->costo = $request->costo;
$nuevoIngreso->duracion = $request->duracion;
$nuevoIngreso->mantenimiento = $request->mantenimiento;
$nuevoIngreso->save();
Updated
<form method="POST" action="{{ route('actualizar') }}">
{{method_field('PUT')}}
#csrf
#foreach ($servicios as $key=>$costo)
<h1 class="text-center text-primary"> {{$costo->tipo}} </h1>
<input class="form-control" type="hidden" value="{{$costo->id}}" name="service[{{$key}}][id]">
<div class="form-group row">
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Costo</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->costo}}" name="service[{{$key}}][costo]">
</div>
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Duración</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->duracion}}" id="example-text-input" name="service[{{$key}}][duracion]">
</div>
<label for="example-text-input" class="col-md-2 col-form-label form-control-label">Mantenimiento</label>
<div class="col-md-10">
<input class="form-control" type="text" value="{{$costo->mantenimiento}}" id="example-text-input" name="service[{{$key}}][mantenimiento]">
</div>
</div>
<hr>
#endforeach
<button type="submit" class="btn btn-success float-right" float-rightdata-toggle="sweet-alert" data-sweet-alert="success">SAVE</button>
</form>
Then in controller
foreach($request->service as $key=>$value){
$nuevoIngreso =new \App\Models\Servicio::find($value['id']);
if($nuevoIngreso){
$nuevoIngreso->costo = $value['costo'];
$nuevoIngreso->duracion = $value['duracion'];
$nuevoIngreso->mantenimiento = $value['mantenimiento'];
$nuevoIngreso->save();
}
}

I keep getting an Integrity constraint violation when I'm trying to submit data to db

I have this problem and I have no idea why it's not working. I have tried so many code changes but I still get the same error when I try to submit a form. It's a simple form to insert data to tomany tables in db. All tables accept data with no error but payment_agrement table gives me this error:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kassemschool.payment_agrements, CONSTRAINT payment_agrements_responisbleid_foreign FOREIGN KEY (responsible_id) REFERENCES payment_agrements (id)) (SQL: insert into payment_agrements (frais_inscription, payment_mois, Assurance, Garde, Transport, responsible_id, updated_at, created_at) values (450, 550, 400, 200, 300, 154, 2019-11-16 19:47:39, 2019-11-16 19:47:39))
This is my controller:
if(request()->has('rName')) {
$responsible = Responsible::create([
'ResponsibleName'=> $request->rName,
'ResponsibleCNI'=>$request->cni,
'responsible_number'=>$request->tele
]);
}
//Student::create($data);
if(request()->has('MontantP')) {
$payment=Payment::create([
'PaymentPaid'=>$request->MontantP,
'PaymentRemaining'=>$request->RestP,
'responsible_id'=>$responsible->id,
]);
}
if($request->hasFile('file')){
$student->images = $request->file->store('file');
}
if(request()->has('TransportR')) {
$transport=Transport::create([
'TransportPaid'=> $request->TransportP,
'TransportRemainning'=>$request->TransportR,
'TransportDateStart'=>$request->TdateStart,
'TransportDateEnd'=>$request->TdateEnd,
]);
}
if(request()->has('edateStart')) {
$payment_date = Payment_Date::create([
'PaymentDateStart'=>$request->edateStart,
'PaymentDateEnd'=>$request->edateEnd,
'payment_id'=>$payment->id,
]);
$letter = 'KassN';
$number =$request->env . 'G';
$number2 = $request->group;
$id='_'.rand();
$random = $letter.$number.$number2.$id;
if(request()->has('fName')) {
$student = Student::create([
'StudentFName'=> $request->fName,
'StudentLName'=> $request->lName,
'StudentDateStart'=>$request->edateStart,
'StudentDateEnd'=>$request->edateEnd,
'level_id'=> $request->env,
'group_id'=>$request->group,
'responsible_id'=> $responsible->id,
'payment_date_id'=>$payment_date->id,
'Payment_dure_id'=>$request->paymentD,
'payment_id'=>$payment->id,
'transport_id'=>$transport->id,
'student_code'=>$random
]);
}
if(request()->has('inscription')){
$agrement= Payment_agrement::create([
'frais_inscription'=>$request->inscription,
'payment_mois'=>$request->payment,
'Assurance'=>$request->assaurance,
'Garde'=>$request->garde,
'Transport'=>$request->fraiTransport,
'responsible_id'=>$responsible->id
]);
}
my create view
#extends('layouts.app')
#section('content')
#if (Route::has('login'))
#auth
#if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
back to <strong>Home</strong>
back to <strong>list</strong>
</div>
#endif
<div class="mr-auto offset-md-1" style="width: 200px;">
<input type="button" class="btn btn-danger btn-sm" name="" value="<- Reteur">
</div>
<div class="card-body">
<div class="container" style="width: 80%;">
<form action="{{url('student')}}" method="POST">
{{ csrf_field() }}
<div class="form-group">
<label for="firstName">First Name </label>
<input type="text" class="form-control" name="fName" id="elastName">
</div>
<div class="form-group">
<label for="lastName">Last name:</label>
<input type="text" class="form-control" name="lName" id="efirstName">
</div>
<div class="form-group">
<label for="responsable">Responsable Name:</label>
<input type="text" class="form-control" name="rName" id="responsable">
</div>
<div class="form-group">
<label for="cni">Responsable CNI:</label>
<input type="text" class="form-control" name="cni" id="cni">
</div>
<div class="form-group">
<label for="nuveau">Niveau:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="nuveau">Options</label>
</div>
<select class="custom-select" id="nuveau" name="env">
<option selected>Choose...</option>
#foreach($levels as $level)
<option value="{{$level->id}}">{{$level->LevelName}} </option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<fieldset>
<legend>Aggrement:<hr></legend>
<div class="form-group">
<label for="cni">Frais de inscription:</label>
<input type="text" class="form-control" name="inscription" id="cni">
</div>
<div class="form-group">
<label for="cni">paiement mensuel:</label>
<input type="text" class="form-control" name="payment" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de Assurance:</label>
<input type="text" class="form-control" name="assaurance" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de Garde:</label>
<input type="text" class="form-control" name="garde" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de transport:</label>
<input type="text" class="form-control" name="fraiTransport" id="cni">
</div>
</fieldset>
</div>
<div class="form-group">
<label for="nuveau">Group:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="group">Options</label>
</div>
<select class="custom-select" id="nuveau" name="group">
<option selected>Choose...</option>
#foreach($groups as $group)
<option value="{{$group->id}}">{{$group->group_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="payment">Payment:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="payment">Options</label>
</div>
<select class="custom-select" id="payment" name="paymentD">
<option selected>Choose...</option>
#foreach($payment_dures as $payment_dure)
<option value="{{$payment_dure->id}}">{{$payment_dure->payment_dure_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="dateStart"></label>
<input type="date" class="#" id="dateStart" style="width: 49%;" name="edateStart">
<label for="dateEnd">au:</label>
<input type="date" class="#" id="dateEnd" style="width: 44%;" name="edateEnd">
</div>
<div class="form-group">
<label for="MontantP">Montant paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" name="MontantP" placeholder="" id="MontantP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="RestP">Rest a paye paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="MontantR" name="RestP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1" style="width: 100%">Bus subscribtion</a>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
<div class="form-group">
<div class="form-group">
<label for="TMontantP">Montant paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="TMontantP" name="TransportP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="TRestP">Rest a paye paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="TRestP" name="TransportR">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="TdateStart"></label>
<input type="date" class="#" id="TdateStart" style="width: 48%;" name="TdateStart">
<label for="dTateEnd">au:</label>
<input type="date" class="#" id="TdateEnd" style="width: 44%;" name="TdateEnd">
</div>
</div>
</div>
</div>
</div>
</div>
</p>
<br>
<button type="submit" class="btn btn-secondary">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
#else
<div class="d-flex justify-content-center text-center">
<div class="alert alert-danger" role="alert" style="width: 70%">
identifié vous d'abord
</div>
</div>
#endauth
#endif
#endsection
Looks like your foreign key constraint isn't setup correctly. From the look of the error you have setup payment_agrements.responsible_id to point to payment_agrements.id instead of responsibles.id.
In the migration for that table, that field probably looks like this:
$table->foreign('responsible_id')->references('id')->on('payment_agrements');
When it should be:
$table->foreign('responsible_id')->references('id')->on('responsibles');

How do i update the content in my database?

I am trying to update values I got from the database but it seems not to be going to the routes function
I tried changing the routes method and even die down the request but it seems not to work
Here is the route
Route::put("/users/bonus/update/{id}",
[
"uses" => "AdminDashboardController#updatebonus",
"as"=> "userbonus.mer"
]);
below is the function that is been called to update
public function updatebonus(Request $request, $id)
{
if (auth()->user()->isAdmin != 1) {
return redirect()->route('home');
} else if (auth()->user()->isAdmin == 1) {
$bonus=OtherBonus::where('id','=','$id')->first();
$bonus->card_bonus=trim(strip_tags($request['cbonus']));
$bonus->monthly_bonus=trim(strip_tags($request['mbonus']));
$bonus->travelling_bonus=trim(strip_tags($request['tbonus']));
$bonus->festival_bonus=trim(strip_tags($request['fbonus']));
$bonus->save();
return redirect()->back()->with("success", "Bonus Settings
Successfully updated");
}
}
below is the form that passes the data to the function which communicates with the database.
<form class="form-horizontal form-label-left" action="{{route('userbonus.mer', ['id'=>$bonus['id']])}}" method="PUT">
<span class="section">General Bonus in %age</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="cbonus">Card
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control col-md-7 col-xs-12"
value="{{$bonus['card_bonus']}}" name="cbonus"
placeholder="10.00%" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="fbonus">Festival
Bonus<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="fbonus" required="required"
value="{{$bonus['festival_bonus']}}"
class="form-control col-md-7 col-xs-12" placeholder="34.6%">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="mbons">Monthly
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="mbonus" required="required"
value="{{$bonus['monthly_bonus']}}" placeholder="56.9%"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbonus">Travelling
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="tbonus" placeholder="0.89%"
value="{{$bonus['travelling_bonus']}}" required="required"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="reset" class="btn btn-primary">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
The HTML form doesn't accept PUT as method. It only works with GET and POST. Have a look here. So if you write
<form method="PUT"></form>
you're going to submit the form as a GET request. Laravel listens for a specific input that has to present after form submission in order to recognize the PUT method. Have a look at the official documentation
HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method:
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
You may use the #method Blade directive to generate the _method input:
<form action="/foo/bar" method="POST">
#method('PUT')
#csrf
</form>
Try This
public function updatebonus(Request $request, $id)
{
if (auth()->user()->isAdmin != 1) {
return redirect()->route('home');
} else if (auth()->user()->isAdmin == 1) {
$bonus=OtherBonus::find($id);
$bonus->update([
'monthly_bonus'=>$request->mbonus,
'travelling_bonus'=>$request->tbonus,
'festival_bonus'->$request->fbonus;
]);
return redirect()->back()->with("success", "Bonus Settings
Successfully updated");
}
}
And BLADE FILE JUST CHANGE METHOD TO post & and after this add {{method_field('PUT')}}
{{csrf_field()}}
<form class="form-horizontal form-label-left" action="{{route('userbonus.mer', ['id'=>$bonus['id']])}}" method="post">
{{method_field('PUT')}}
{{csrf_field()}}
<span class="section">General Bonus in %age</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="cbonus">Card
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control col-md-7 col-xs-12"
value="{{$bonus['card_bonus']}}" name="cbonus"
placeholder="10.00%" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="fbonus">Festival
Bonus<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="fbonus" required="required"
value="{{$bonus['festival_bonus']}}"
class="form-control col-md-7 col-xs-12" placeholder="34.6%">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="mbons">Monthly
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="mbonus" required="required"
value="{{$bonus['monthly_bonus']}}" placeholder="56.9%"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbonus">Travelling
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="tbonus" placeholder="0.89%"
value="{{$bonus['travelling_bonus']}}" required="required"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="reset" class="btn btn-primary">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
In Route make it post

how to write ckeditor code in laravel form view in laravel

Hello everyone i want to add ckeditor in my view which has multiple divs. How can i do that by adding this ckeditor code:
<title>A Simple Page with CKEditor</title>
<script src="../ckeditor.js"></script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
And this is my view
#extends('sadmin.main-template')
#section('title', 'Super admin Dashboard')
#section('title', 'Add Plan')
#section('content')
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 right-sidebar admin-client add-client">
#include('partials.errors')
<form action="{{url('sadmin/add_plan')}}" class="toggle-disabled" method="post">
{!! csrf_field() !!}
<h3 class="title">Add a plan</h3>
<div class="form-group">
<label >You Can Create Your Plan Here</label>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Name</span>
<input type="text" class="form-control" id="name" name="name" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Price</span>
<input type="text" class="form-control" id="name" name="price" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Allowed Users</span>
<input type="text" class="form-control" id="name" name="allowed_users" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Can Trail</span>
<input type="text" class="form-control" id="canTrail" name="can_trail" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="form-group">
<label class="form-label name">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<span class="form-name">Trail Duration</span>
<input type="text" class="form-control" id="password" name="trail_duration" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Detail 1</span>
<input type="text" class="form-control" id="passwordConfirmation" name="detail1" placeholder="" data-validation="custom" data-validation="required">
</label>
</div>
</div>
<div class="form-group">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<label class="form-label name">
<span class="form-name">Detail 2</span>
<input type="text" class="form-control" id="phoneNumber" name="detail2" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Staff Profiles</span>
<input type="text" class="form-control" id="planName" name="staff_profiles" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Space Management</span>
<input type="text" class="form-control" id="planPrice" name="space_management" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Currency Unit</span>
<input type="text" class="form-control" id="allowedUsers" name="currency_unit" placeholder=""data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$" >
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Location charges</span>
<input type="text" class="form-control" id="allowedUsers" name="location_charges" placeholder=""data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$" >
</label>
</div>
</div>
</div>
<p> </p>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center">
<div align="center">
<button type="submit" class="btn btn-success" style="padding-left:90px; padding-right:90px;"><strong>Submit</strong></button>
</div>
</div>
</div>
</section>
</div>
#endsection
How i can apply ckeditor code in each div any help would be appreciated.

how to save data/records from html form to DB2 database

this is my html form
<form class="form-horizontal" id="myCredantials" >
<div class="form-group">
<label class="col-sm-2 control-label">Username : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbUsername" placeholder="Username">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Email : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Gender : </label>
<div class="col-sm-10 col-md-2">
<select id="cbmGender">
<option value="-1">Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Date : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbDate">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Price : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" value="0" id="tbPrice" placeholder="Prices">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Perc % : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" value="0" id="tbPercentage" placeholder="%">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Password : </label>
<div class="col-sm-10 col-md-2">
<input type="password" class="form-control" id="tbPassword" placeholder="Password">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Confirm Password : </label>
<div class="col-sm-10 col-md-2">
<input type="password" class="form-control" id="tbConfirmpassword" placeholder="Confirm">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" class="btn btn-primary " id="btnSubmit" onclick="onSave()" value="Save" >
<input type="button" class="btn btn-primary " id="btnClear" onclick="onClearError()" value="Remove Error" >
<input type="button" class="btn btn-primary " id="btnGet" onclick="doGet()" value="Get" >
<input type="button" class="btn btn-primary " id="btnGet" onclick="doPost()" value="Post" >
</div>
</div>
<div style="width:700px;">
<table cellpadding="0" cellspacing="0" border="0" width="700" id="tbl_Credantials">
</table>
</div>
</form>

Resources