Tying to access item tables in first loop and values of the 2nd loop in a select in laravel. How do i do this? I get an error:
Trying to get property 'unit_abb' of non-object (View: C:\xampp\htdocs\ein\IPPS\resources\views\pr-items.blade.php)
Here is my code:
pr-items.blade
#foreach($list as $indexKey => $list)
<form class="form-horizontal" role="form" method="POST" action="{{ url('/update_items',$list->id) }}" autocomplete="off" >
{{ csrf_field() }}
{{ method_field('PATCH') }}
<input type="hidden" value="{{$list->pr_form_number}}" name='prlist' id='prlist'>
<tr>
<th>
</th>
<td>
<input type="text" class="form-control custom-border input-sm" value="{{$list->pr_qty}}" name="qtylist" id="qtylist" >
</td>
<td>
<select id="department" type="text" class="form-control custom-border input-sm" name="unitlist" id="unitlist">
#foreach ($units as $key => $newunit)
#if ($loop->parent->first)
<option value="{{$newunit->unit_abb}}" #if($newunit->unit_abb == $list->pr_unit) selected #endif>{{$newunit->unit_name}}</option>
#endif
#endforeach
</select>
</td>
<td>
<input type="text" class="form-control custom-border input-sm" value="{{$list->pr_description}}" name="descriptionlist" id="descriptionlist" >
</td>
<td>
<input type="text" class="form-control custom-border input-sm money-inp" value="{{$list->pr_cost_per_unit}}" name="cpulist" id="cpulist">
</td>
<td>
<input type="text" class="form-control custom-border input-sm money-inp" value="{{$list->pr_estimated_cost}}" disabled>
</td>
<td class="text-center">
<button type="submit" class="btn btn-warning btn-sm glyphicon glyphicon-pencil"></button>
<a class="btn btn-danger btn-sm glyphicon glyphicon-minus" href="{{route('pr.delete',$list->id)}}"></a>
</td>
</tr>
</form>
#endforeach
Related
and I have a problem with how to enter images into the data base, in the case of the presence of input fields that increase or decrease in the case of addition or deletion
This is the code for adding data to the database
$products = $request->day_book_id;
for ($i=0; $i<count($products); $i++) {
$items = new Daybooks_units();
$items->debit= $request->debit[$i];
$items->creditor= $request->creditor[$i];
$items->data= $request->data[$i];
$items->reference= $request->reference[$i];
$items->files= $request->reference[$i];
$items->files = uploadImage('filesDayBooks',$request->images)[$i];
$items->dayBook_code= $request->dayBook_code[$i];
$items->fullAccounting_id= $request->fullAccounting_id[$i];
$items->day_book_id= $request->day_book_id[$i];
$items->branch_id= $request->branch_id[$i];
$items->save();
This is the code for the blade
<td style="padding:3px" >
<input type="text" class="search" name="search" required>
<select class="form-control search_list getData" id="search_list" name="fullAccounting_id[]"></select>
#error('fullAccounting_id')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
</td>
<td style="display:none" >
<input type="text" value=" " class=" form-control putParentId" name="ParentOfAccounting_manual_id[]">
</td>
<td style="display:none">
<input type="text" value=" " class=" form-control putCode" name="code_accountingManuals[]">
</td>
<td style="display:none">
<input type="text" value=" " class=" form-control debtor_creditor" name="debtor_creditor[]">
</td>
<td style="padding:3px">
<input type="text" value="0" class=" form-control totaldebit" onchange="getTotalRowPrice(this , '{{-500}}' )" name="debit[]">
#error('debit')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
</td>
<td style="width:100px;">
<input type="text" onchange="getTotalRowPrice(this , '{{-500}}' )" value="0" class=" form-control totalcreditor" name="creditor[]">
#error('creditor')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
</td>
<td style="padding:3px">
<input type="text" value="" class=" form-control" name="data[]">
</td>
<td style="width:100px;">
<select name="branch_id[]" required class="form-control">
<option></option>
#foreach($costCenters as $costCent)
<option value="{{$costCent->id}}">{{$costCent->name}}</option>
#endforeach
</select>
#error('branch_id')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
</td>
<td style="padding:3px">
<input type="text" class="form-control " name="reference[]" value="">
</td>
<td style="display:none;">
<input type="text" class="form-control " name="id_unit[]" value="{{ $id_unit }}">
</td>
<td style="display:none;">
<input type="text" class="form-control " name="daybooks_units[]" value="daybooks_units">
</td>
<td style="padding:3px">
<input type="file" name="images[]" multiple class="form-control" id="customFile">
</td>
<td style="padding:3px">
<input type="button" class="btn btn-success" name="add" id="add" value="add" style="color: white">
</td>
The function works smoothly if no images are inserted, but when images are uploaded, this error appears
I have no idea what your custom (not shared) uploadeImage function does, but the error SHOULD be here:
// You coded
$items->files = uploadImage('filesDayBooks',$request->images)[$i];
// It should be
$items->files = uploadImage('filesDayBooks',$request->images[$i]);
If that is not the error, please share uploadeImage code
I use laravel 7. I want to add additional modal with value before submit.
When I try to update data without additional modal, the update works correctly. But when I add the additional modal with value, the program success but my update not works correnctly. This is my form (blade view):
<div class="col-md-10">
<form method="POST" action="{{ url('/quotation/updateQuotation', $id) }}"
enctype="multipart/form-data">
#csrf
<div class="card">
<div class="card-body bg-light-white ">
<div class="tab-content">
<table width="100%">
<tr>
<td>Quotation No<span class="required" style="color: red">*</span></td>
<td>
<div class="form-group col-md-9">
<span style="display: flex;">
<input type="text" name="qno" style="width: 20%;"
class="form-control form-control-sm"
value="{{ $qno }}" readonly />
<input type="text" name="quotation_no" style="width: 60%;"
class="form-control form-control-sm"
value="{{ $quotation->quotation_no }}" readonly />
</span>
</div>
</td>
<td>Quotation Date<span class="required" style="color:red"></td>
<td>
<div class="form-group col-md-9">
<input type="date" name="quotation_date"
class="form-control form-control-sm"
value="{{ $quotation->quotation_date }}" />
</div>
</td>
</tr>
<tr>
<td>Ref. No</td>
<td>
<div class="form-group col-md-9">
<input type="text" name="ref_no" style="width: 80%"
class="form-control form-control-sm"
value="{{ $quotation->ref_no }}" />
</div>
</td>
<td>Request Date</td>
<td>
<div class="form-group col-md-9">
<input type="date" name="request_date"
class="form-control form-control-sm"
value="{{ $quotation->request_date }}" />
</div>
</td>
</tr>
<tr>
<td>Request By</td>
<td>
<div class="form-group col-md-9">
<input type="text" name="request_by"
class="form-control form-control-sm"
value="{{ $quotation->request_by }}" style="width: 80%" />
</div>
</td>
<td>Currency<span class="required" style="color:red"></td>
<td>
<div class="form-group col-md-9">
<select class="form-control selectpicker" data-live-search="true"
style="width: 80%;" aria-label="1 -10" id="currency"
name="currency">
{{-- munculkan option data dari table --}}
<option value="{{ $quotation->currency }}" selected>
{{ $quotation->currency }}</option>
{{-- list option dari table currency --}}
#foreach ($curency as $val2)
<option value="{{ $val2->code }}"
data-token="{{ $val2->name }}">{{ $val2->code }}
</option>
#endforeach
</select>
</div>
</td>
</tr>
<tr>
<td>Insurance Period<span class="required" style="color:red"></td>
<td>
<div class="form-group col-md-9">
<span style="display: flex;">
<input type="date" name="start_period" style="width: 40%;"
class="form-control form-control-sm"
value="{{ $quotation->start_period }}" />
<input type="date" name="end_period" style="width: 40%;"
class="form-control form-control-sm"
value="{{ $quotation->end_period }}" />
</span>
</div>
</td>
<td>Quotation Type</td>
<td>
<div class="form-group col-md-9">
<select name="quotation_type" class="form-control" id="quotation_type">
#if ($quotation->quotation_type == 1)
<option value="1">Tipe 1</option>
#endif
#if ($quotation->quotation_type == 2)
<option value="2">Tipe 2</option>
#endif
<option value="1">Tipe 1</option>
<option value="2">Tipe 2</option>
</select>
</div>
</td>
</tr>
<tr>
<td>Ceding<span class="required"></td>
<td>
<div class="form-group col-md-9">
<select class="form-control selectpicker" data-live-search="true"
name="ceding_id" style="width: 80%;" aria-label="1 -10" required>
#if ($quotation->ceding_id == null)
<option value="" data-tokens=""></option>
#endif
#foreach ($cedding as $val2)
#if ($quotation->ceding_id == $val2->code)
<option value="{{ $val2->code }}"
data-tokens="{{ $val2->name }}">
{{ $val2->code . '-' . $val2->name }}</option>
#endif
#endforeach
#foreach ($cedding as $val2)
<option value="{{ $val2->code }}"
data-tokens="{{ $val2->name }}">
{{ $val2->code . '-' . $val2->name }}</option>
#endforeach
</select>
</div>
</td>
<td>Payment Mode</td>
<td>
<div class="form-group col-md-9">
<select class="form-control selectpicker" data-live-search="true"
aria-label="1 -10" name="payment_mode" id="payment_mode">
#if ($quotation->payment_mode == 1)
<option value="1">Annually</option>
#endif
#if ($quotation->payment_mode == 2)
<option value="2">Semi Annually</option>
#endif
#if ($quotation->payment_mode == 4)
<option value="4">Quaterly</option>
#endif
#if ($quotation->payment_mode == 12)
<option value="12">Monthly</option>
#endif
<option value="1">Annually</option>
<option value="2">Semi Annually</option>
<option value="4">Quaterly</option>
<option value="12">Monthly</option>
</select>
</div>
</td>
</tr>
<tr>
<td>Company<span class="required"></td>
<td>
<div class="form-group col-md-9">
<select class="form-control selectpicker" data-live-search="true"
name="company_profile" style="width: 80%;" aria-label="1 -10"
required>
#if ($quotation->company_profile == null)
<option value="" data-tokens=""></option>
#endif
#foreach ($company as $val2)
#if ($quotation->company_profile == $val2->company_profile)
<option value="{{ $val2->company_profile }}"
data-tokens="{{ $val2->company_profile }}" selected>
{{ $val2->company_profile }}</option>
#endif
#endforeach
#foreach ($company as $val2)
<option value="{{ $val2->company_profile }}"
data-tokens="{{ $val2->company_profile }}">
{{ $val2->company_profile }}</option>
#endforeach
</select>
</div>
</td>
<td>Installment<span class="required" style="color:red"></td>
<td>
<div class="form-group col-md-9">
<input id="installment" type="text" name="qty_installment"
class="form-control" readonly
value="{{ $quotation->qty_installment }}">
</div>
</td>
</tr>
<tr>
<td>Product Brand<span class="required"></td>
<td>
<div class="form-group col-md-9">
<select class="form-control selectpicker" data-live-search="true"
name="product_brand" style="width: 80%;" aria-label="1 -10"
required>
#if ($quotation->product_brand == null)
<option value="" data-tokens=""></option>
#endif
#foreach ($productbrand as $val2)
#if ($quotation->product_brand == $val2->product_brand && $quotation->company_profile == $val2->company_profile && $quotation->ceding_id == $val2->ceding_id)
)
<option value="{{ $val2->product_brand }}"
data-tokens="{{ $val2->product_brand }}">
{{ $val2->product_brand . '-' . $val2->description }}
</option>
#endif
#endforeach
#foreach ($productbrand as $val2)
<option value="{{ $val2->product_brand }}"
data-tokens="{{ $val2->product_brand }}">
{{ $val2->product_brand . '-' . $val2->description }}
</option>
#endforeach
</select>
</div>
</td>
<td>Quotation Category</td>
<td>
<div class="form-group col-md-9">
<select name="quotation_category" class="form-control"
id="quotation_category">
#if ($quotation->quotation_category == 'konvensional')
<option value="konvensional">Konvensional</option>
#endif
#if ($quotation->quotation_category == 'syariah')
<option value="syariah">Syariah</option>
#endif
<option value="konvensional">Konvensional</option>
<option value="syariah">Syariah</option>
</select>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="align-items-right">
{{-- <button class="btn btn-success" style="float: right; margin: 10px;">
{{ __('Simulasi Premi ') }}
</button> --}}
{{-- <input type="submit" class="btn btn-success" value="Update"
style="float: right; margin: 10px;"> --}}
<button type="button" class="btn btn-success" data-id="2014-123456" data-toggle="modal"
data-target="#modalRevisi">Update</button>
</div>
</div>
{{-- start here modal revisi --}}
<div id="modalRevisi" class="modal fade" role="dialog">
<div>
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="height:50px;">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<label>Revisi:</label>
<select name="tipe_revisi" id="tipe_revisi" class="form-control">
<option value="internal">Internal</option>
<option value="eksternal">Eksternal</option>
</select>
</div>
<div class="modal-footer text-center" style="display:inline;">
<!-- <input type="submit" class="btn btn-primary" value="Cash" name="login" style="background-color:rgb(0,30,66); "> -->
<button type="button" class="btn btn-danger"
data-dismiss="modal">Cancel</button>
<input type="submit" class="btn btn-primary" value="Submit" name="submit"
style="background-color:rgb(0,30,66); ">
</div>
</div>
</div>
</div>
{{-- </form> --}}
</div>
{{-- end here modal revisi --}}
</form>
</div>
This is th updateController:
public function updateQuotation(Request $request,QuotationLog $log, $id)
{
// dd($request);
$user = Auth::user();
$validator = $request->validate([
'qno' => 'required',
]);
// dd($request->product_plan);
$quotation = Quotation::find($id);
if ($validator) {
try{
$quotation = Quotation::find($id);
$quotation->qno = $request->qno;
$quotation->quotation_no = $request->quotation_no;
$quotation->quotation_date = $request->quotation_date;
$quotation->ref_no = $request->ref_no;
$quotation->request_date = $request->request_date;
$quotation->request_by = $request->request_by;
$quotation->currency = $request->currency;
$quotation->start_period = $request->start_period;
$quotation->end_period = $request->end_period;
$quotation->quotation_type = $request->quotation_type;
$quotation->quotation_category = $request->quotation_category;
$quotation->payment_mode = $request->payment_mode;
$quotation->qty_installment = $request->qty_installment;
$quotation->ceding_id = $request->ceding_id;
$quotation->company_profile = $request->company_profile;
$quotation->product_brand = $request->product_brand;
$quotation->expired_claim_receipt = $request->expired_claim_receipt;
$quotation->overwrite_membership_premi_f = $request->overwrite_membership_premi_f;
$quotation->prorate_claim_f = $request->prorate_claim_f;
$quotation->uw_year = $request->uw_year;
$quotation->user = $user->name;
$quotation->tipe_revisi = $user->tipe_revisi;
$quotation->save();
//update table log
$log->qno = $request->qno;
$log->quotation_no = $request->quotation_no;
$log->quotation_date = $request->quotation_date;
$log->ref_no = $request->ref_no;
$log->request_date = $request->request_date;
$log->request_by = $request->request_by;
$log->currency = $request->currency;
$log->start_period = $request->start_period;
$log->end_period = $request->end_period;
$log->quotation_type = $request->quotation_type;
$log->quotation_category = $request->quotation_category;
$log->payment_mode = $request->payment_mode;
$log->ceding_id = $request->ceding_id;
$log->company_profile = $request->company_profile;
$log->product_brand = $request->product_brand;
$log->expired_claim_receipt = $request->expired_claim_receipt;
$log->overwrite_membership_premi_f = $request->overwrite_membership_premi_f;
$log->prorate_claim_f = $request->prorate_claim_f;
$log->uw_year = $request->uw_year;
$log->remarks = $request->remarks;
$log->kind_of_contract = $request->kind_of_contract;
$log->user_id = $user->id;
$log->user_name = $user->name;
$log->ip_address = $this->get_client_ip();
$log->action = 'EDIT';
$log->tipe_revisi = $user->tipe_revisi;
$log->save();
$notification = array(
'message' => 'Quotation updated successfully!',
'alert-type' => 'success'
);
return back()->with($notification);
}catch (\Illuminate\Database\QueryException $ex) {
dd($ex);
$message = DB::table('health_sys_error')
->select('error_message')
->where('error_id','=',$ex->errorInfo[1])
->first();
$notification = array(
'message' => $message->error_message == null ? 'Error, Contact Admin!' : $message->error_message,
'alert-type' => 'error'
);
return back()->with($notification)->withInput();
}
} else {
return back()->with($validator)->withInput();
}
}
I have done to add in models and migration. My program return success, but tipe_revisi field not inserted. Why?
use
$quotation->tipe_revisi = $request->tipe_revisi;
instead
$quotation->tipe_revisi = $user->tipe_revisi;
because you get data from form
I think you should change this code, becoz this is a field name in form.
$user->tipe_revisi
to
$request->tipe_revisi
i am new in laravel this is my first app well,
i want to display all operations between 2 dates insert by user but i got this error(Argument 2 passed to Illuminate\Database\Query\Builder::whereBetween() must be of the type array, null given, called in C:\Users\tgtv\Desktop)
operation table (id , vehicule , date, personnel_id)
okay now this is my search blade php
<form method="post" action="{{ route('etatperso.store') }}" enctype="multipart/form-data" width="20" height="20">
#csrf
<div class="form-group">
<label class="col-md-4">Personnel :</label>
<div class="col-md-8">
<select name="personnel_id" id="personnel_id" class="form-control" >
<option value="">Select Personnel</option>
#foreach($personnels as $personnel)
<option value="{{ $personnel->id}}">{{ $personnel->nom }}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4">Date debut :</label>
<div class="col-md-8">
<input type="date_debut" name="date_fin" value="{{ old('date', date('Y-m-d')) }}" class="form-control input-lg" />
</div>
</div>
<div class="form-group">
<label class="col-md-4">Date fin</label>
<div class="col-md-8">
<input type="date_fin" name="date_fin" value="{{ old('date', date('Y-m-d')) }}" class="form-control input-lg" />
</div>
</div>
<br/>
<div class="form-group text-center">
<input type="submit" name="add" class="btn btn-primary input-lg" value="Ajouter Personnel" />
</div>
</form>
and this is my function search in the controller
public function store(Request $request)
{
$personnels = Personnel::all();
$personnel_id=$request->get('personnel_id');
$date_debut=$request->get('date_debut');
$date_fin=$request->get('date_fin');
$data =Operation::where('personnel_id','LIKE',$personnel_id)->whereBetween('date',$date_debut,$date_fin)->paginate(1000);
return view('etatperso.resultat', compact('data','personnels'));
}
and finnaly this is my result.blade.php
<table class="table table-bordered table-striped">
<th width="10%">ID</th>
<th width="10%">Vehicule</th>
<th width="10%">Personnel</th>
<th width="10%">Creation</th>
<th width="10%">Description</th>
<th width="10%">Date</th>
<th width="10%">Etat</th>
<th width="10%">Prix total</th>
</tr>
#foreach($data as $row)
<tr>
<td>{{ $row->id}}</td>
<td>{{ $row->vehicule }}</td>
<td>{{ $row->personnel->nom}}</td>
<td> {{$row->creation}}</td>
<td>{{ $row->description }}</td>
<td>{{ $row->created_at}}</td>
#if($row->etat =="en cours")
<td style="background-color: red;">{{ $row->etat}}</td>
#elseif($row->etat =="paye")
<td style="background-color: green;">{{ $row->etat}}</td>
#endif
<td>{{ $row->prix_total}}</td>
#if($row->etat =="paye")
<td>
Ajouter articles nécessaire
<br> </br>
Liste des Articles Utilisés</td>
#elseif ($row->etat =="en cours")
<td>
Ajouter articles nécessaire
<br> </br>
Ajouter action
<br> </br>
Liste des Articles Utilisés</td>
</tr>
#endif
#endforeach
</table>
WhereBetween second parameter must be in array.
In your code
change this
$data =Operation::where('personnel_id','LIKE',$personnel_id)->whereBetween('date',$date_debut,$date_fin)->paginate(1000);
to
$data =Operation::where('personnel_id','LIKE',$personnel_id)->whereBetween('date',[$date_debut,$date_fin])->paginate(1000);
UPDATE
also change this
<input type="date_debut" name="date_fin" value="{{ old('date', date('Y-m-d')) }}" class="form-control input-lg" />
to
<input type="date_debut" name="date_debut" value="{{ old('date', date('Y-m-d')) }}" class="form-control input-lg" />
Try this :
$data =Operation::where('personnel_id','LIKE',$personnel_id)->whereBetween('date',[$date_debut,$date_fin])->paginate(1000);
Currently i have a form and calling a few data using foreach's like below:
#foreach($db as $intentName => $questionAnswer)
<div class="form-group edit-response-container">
<label data-toggle="collapse" data-target="#collapse-{{$number}}" aria-expanded="false" aria-controls="collapse-{{$number}}"> {{$intentName}} <i class="fa fa-chevron-down"></i></label>
<div class="collapse" id="collapse-{{$number}}">
<div class="well">
<form action="{{action('AltHr\Chatbot\ChatbotController#savedmb', [$companyID, $entityType])}}" method="post">
{{csrf_field()}}
<div class="col-md-12 btn-toolbar">
<button type="button" class="btn alt-btn alt-btn-green pull-right add-new">Add Answer</button>
<button type="submit" class="btn alt-btn alt-btn-green pull-right">Save</button>
</div>
#foreach($questionAnswer['q1'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['q2'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['q3'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['intent'] as $intent => $intent)
<input type="hidden" name="intent" value="{{$intent}}">
#endforeach
<input type="hidden" name="entityValue" value="{{$q}}" readonly/>
<br><br>
<div class="new-field">
<table class="response">
<tr>
<td class="labels"><p>Answer:</p></td>
<td><input type="text" name="newAnswer[]" value=""></td>
</tr>
</table>
</div>
</form>
</div>
</div>
</div>
<?php
$number++;
?>
#endforeach
so the function is all working fine but im having one problem as you can see from the picture below the form is the same but currently the button is showing me on each foreach if im not mistaken but i only want to have ONE submit and ONE add button and not on all foreach. How can i do that?
enter image description here
my controller as below:
public function savedmb(Request $request, $companyID, $entityType)
{
$a = count($request->question);
for ($p=0; $p < $a; $p++) {
$nq = new DiraQuestion;
$nq->intent = strtolower($request->intent);
$nq->eType = $entityType;
$nq->eVal = strtolower($request->entityValue);
//$nq->synonym = strtolower($request->syn);
$nq->queries = $request->question[$p];
$nq->company_id = $companyID;
$nq->save();
}
$x = count($request->newAnswer);
for ($i=0; $i < $x; $i++) {
$nr = new DiraResponses;
$nr->intent = strtolower($request->intent);
$nr->eType = $entityType;
$nr->eVal = strtolower($request->entityValue);
$nr->reply = strtolower($request->newAnswer[$i]);
$nr->company_id = $companyID;
$nr->save();
}
return back();
}
and my route:
Route::post('savedmb/{companyID}/{entityType}','Chatbot\ChatbotController#savedmb');
Place your button out of loop:
<div class="form-group edit-response-container">
<label data-toggle="collapse" data-target="#collapse-{{$number}}" aria-expanded="false" aria-controls="collapse-{{$number}}"> {{$intentName}} <i class="fa fa-chevron-down"></i></label>
<div class="collapse" id="collapse-{{$number}}">
<div class="well">
<form action="{{action('AltHr\Chatbot\ChatbotController#savedmb', [$companyID, $entityType])}}" method="post">
{{csrf_field()}}
<div class="col-md-12 btn-toolbar">
<button type="button" class="btn alt-btn alt-btn-green pull-right add-new">Add Answer</button>
<button type="submit" class="btn alt-btn alt-btn-green pull-right">Save</button>
</div>
#foreach($db as $intentName => $questionAnswer)
#foreach($questionAnswer['q1'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['q2'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['q3'] as $question => $questionID)
<table class="question">
<tr>
<td class="labels"><p>User:</p></td>
<td><p> {{ str_replace("<title>", "$q", $question) }}</p></td>
<input type="hidden" name="question[]" value="{{ str_replace("<title>", "$q", $question) }}">
</tr>
</table>
#endforeach
#foreach($questionAnswer['intent'] as $intent => $intent)
<input type="hidden" name="intent" value="{{$intent}}">
#endforeach
<input type="hidden" name="entityValue" value="{{$q}}" readonly/>
<br><br>
<div class="new-field">
<table class="response">
<tr>
<td class="labels"><p>Answer:</p></td>
<td><input type="text" name="newAnswer[]" value=""></td>
</tr>
</table>
</div>
<?php
$number++;
?>
#endforeach
</form>
</div>
What i need is if i get first element id of MOB/TR/1743 then press the mark button data which relevant to that id must go the database.
This is what should in the database.
But this is what i'm getting into the database. That means getting another column data into database.
Here is the view of that.
<div class="row">
<section id="feature" class="section-padding wow fadeIn delay-05s">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-6 col-xs-12">
<div class="wrap-item text-center">
<div class="jumbotron">
<div class="item-img">
<img src="images/ser02.png">
</div>
<div class="form-group">
<form action="search" method="post" class="form-inline">
<select name="institute" id="institute">
<option selected="selected" value="id">Trainee Id</option>
<option value="full_name">Trainee Name</option>
<label for="Search">Name</label>
</select>
<input type="text" name="search" /><br>
<input type="hidden" value="{{ csrf_token() }}" name="_token" />
<input type="submit" name="submit" value="Search">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="col-md-12 col-sm-6 col-xs-12">
<div class="panel panel-default">
<div class="panel-body">
<table class="table table-striped">
<thead>
<th>Trainee ID</th>
<th>Name with Initials</th>
<th>Time</th>
<th>Mark Here!</th>
</thead>
<tbody>
<form action="{{route('TraineeAttendance.store')}}" method="post" >
{{ csrf_field() }}
#foreach($items as $item)
<tr>
<td>
<div class="form-group">
<input type="text" name="trainee_id" class="form-control" value="{{ $item->trainee_id }}">
</div>
</td>
<td>
<div class="form-group">
<input type="text" name="name" class="form-control" value="{{ $item->name_with_initials }}">
</div>
</td>
<td>
<label><input type="checkbox" name="time" id="time" value="time"> Time</label>
</td>
<td>
<input type="submit" class="btn btn-info">
</td>
</tr>
#endforeach
</form>
</tbody>
</table>
</div>
</div>
</div>
Why i`m getting wrong data?
try this hope it helps
#foreach($items as $item)
<form action="{{route('TraineeAttendance.store')}}" method="post" >
{{ csrf_field() }}
<tr>
<td>
<div class="form-group">
<input type="text" name="trainee_id" class="form-control" value="{{ $item->trainee_id }}">
</div>
</td>
<td>
<div class="form-group">
<input type="text" name="name" class="form-control" value="{{ $item->name_with_initials }}">
</div>
</td>
<td>
<label><input type="checkbox" name="time" id="time" value="time"> Time</label>
</td>
<td>
<input type="submit" class="btn btn-info">
</td>
</tr>
</form>
#endforeach