laravel multiple input insert - laravel

I could not add more than one input value to the database. When the color is selected, the size numbers are listed, I want to save the piece value to these size numbers.
How can I record each input separately?
order_piece table
id|order_id|collection_color_size_barcode_id|piece
HTML code
<div class="table-scrollable" style="font-size: 14px;">
<table class="table">
<thead>
<tr>
<th> size </th>
<th> Barcode </th>
<th> order piece </th>
</tr>
</thead>
<tbody>
#foreach ($collection_color_size_barcode as $collection_color_size_barcode){
<tr>
<td><label class="col-md-3 control-label" style="margin-top: 5px;">{{$collection_color_size_barcode->size}}</label></td>
<td><label class="col-md-3 control-label" style="margin-top: 5px;">{{$collection_color_size_barcode->barcode}}</label></td>
<td>
<div class="col-md-5">
<input type="text" class="form-control input-sm" name="size[][{{$collection_color_size_barcode->id}}][piece]">
</div>
</td>
</tr>
}
</tbody>
</table>
Contoller code
public function OrderAdd(Request $request){
return dd($request->size);
}

Related

Form select is showing entire row not one column

I am trying to make a filter for my table but i see a problem there. Maybe the problem is from table structure couse i fetch all structure as it is on mysql. Does anyone help to make this filter in right way.
The collapse content under comment is the head i display when i want to filter
<table class="table table-hover align-middle mb-0">
<thead class="">
<tr>
<th><input type="checkbox" class="form-check-input" v-model="selectAll" title="Select All"></th>
<th v-if="!isHidden[index]" v-for="(header, index) in visibleHeaders" :key="index" scope="col">
{{ header }}
</th>
<th>ACTION</th>
</tr>
</thead>
<!-- Collapsed content ./ -->
<thead class="collapse" id="collapseFilter">
<tr>
<th>#</th>
<th v-for="(header, index) in visibleHeaders" scope="col">
<select id="" class="form-select" >
<option v-for="column in leads">
<div v-for="(atr, key, index) in column">
{{atr}}
</div>
</option>
</select>
</th>
</tr>
</thead>
<!-- ./ Collapse contet -->
<tbody>
<tr v-show="leads.length" v-for="column in leads" >
<td>
<input type="checkbox" class="form-check-input" v-model="selected" :value="column.id" />
</td>
<td v-if="!isHidden[index]" v-for="(atr, key, index) in column">
<div v-if="atr == 'new'">
<span class="badge bg-info">{{ atr }}</span>
</div>
<div v-else-if="atr == 'contract'">
<span class="badge bg-success">{{ atr }}</span>
</div>
<div v-else>
<span >{{ atr }}</span>
</div>
</td>
<td>
<button #click="editLead(column.id)" type="button" class="btn btn-sm btn-secondary" data-mdb-toggle="modal" data-mdb-target="#editLeadModal" >
<i class="fa-solid fa-eye"></i>
</button>
</td>
</tr>
<tr v-show="!leads.length">
<td colspan="12" class="text-center">Sorry :( No data found.</td>
</tr>
</tbody>
</table>
If i try to loop only v-for="column in lead"

How to redirect back to previous page after post request in laravel?

I have a system where user enters the date range from and to and gets all required data between that date range. Data retrieved from the database shows in the table containing checkbox to each row. When user Check the check box and submit the data it updates to the database, but I'm have to redirect to the same table after updating the data in database. It says the GET method is not supported for this route. Supported methods: POST. Need Help.
Here is my Date range fill view.
#extends('master')
#section('content')
<div class="input-group" style="margin:50px">
<table>
<form action="/payment_list_table" method="POST">
#csrf
<div class="form-outline">
<tr>
<th>
<label>From</label>
</th>
<th>
<input type="date" name= 'from' class="form-control" placeholder="Doc Received Date" required="" />
</th>
<th>
<label>To</label>
</th>
<th>
<input type="date" name= 'to' class="form-control" placeholder="Doc Received Date" required="" />
</th>
</tr>
<th>
<button type="submit" class="btn btn-success">
<i class="fas fa-search"></i>
</button>
</th>
</div>
</form>
</table>
</div>
#endsection
Here is my Search Table View
#extends('master')
#section('content')
<div class='container' style="margin-top:50px">
<div class="row">
<div class="input-group" style="margin:20px">
<form>
<table style="float:right">
<th>
<div class="form-outline">
<input type="search" id="form1" class="form-control" placeholder="Search"/>
</th>
</form>
</div>
<form method="POST">
#csrf
<button type="submit" formaction="#" name="submit" class="checklistpo">PO</button>
<button type="submit" formaction="#" name="submit" class="ajax.po">AO</button>
<div class="table-responsive">
<table class="table custom-table">
<thead>
<tr>
<th scope="col">
<label class="control control--checkbox">
<input type="checkbox" class="js-check-all"/>
<div class="control__indicator"></div>
</label>
</th>
<th scope="col" >S.N</th>
<th scope="col">LC NO</th>
<th scope="col">Applicant</th>
<th scope="col">Doc Value</th>
<th scope="col">Doc Received date</th>
<th scope="col">LC Type</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php $number = 1;?>
#foreach($datas as $items)
<tr>
<td><input type="checkbox" name="checkboxlist[]" value="{{$items->id}}" /></td>
<td>{{$number}}</td>
<td>{{$items->lc_no}}</td>
<td>{{$items->applicant}}</td>
<td>{{$items->doc_value}}</td>
<td>{{$items->rec_date}}</td>
<td>{{$items->sight_usance}}</td>
</tr>
<?php $number++; ?>
#endforeach
</tbody>
</table>
</div>
</form>
</div>
</div>
#endsection
Here is my Controller
function po(Request $req){
$validate=Validator::make($req->all(), [
"checkboxlist" => "required|array"
]);
foreach($req->checkboxlist as $list){
$data = Doc::find($list);
$data->payment_comment = "PO";
$data->Payment_status = "Prepared";
$data->save();
};
return Redirect::back();
if($validate->fails()){
return redirect()->back()->with("errors",$validate->errors());
}
}
And My Route
Route::post('po', [PaymentController::class, 'po']);
Your code needs a bit of formatting & make more understandable variables but anyways. You need to check if validation fails before foreach. return redirect()->back(); is the right way to go back.
function po(Request $req)
{
$validate = Validator::make($req->all(), [
"checkboxlist" => "required|array"
]);
if ($validate->fails()) {
return redirect()->back()->with("errors", $validate->errors());
}
foreach ($req->checkboxlist as $list) {
$data = Doc::find($list);
$data->payment_comment = "PO";
$data->Payment_status = "Prepared";
$data->save();
}
return redirect()->back();
}

How get Multiple Checkbox value in Controller submitted from the form in laravel?

I have the table with each row containing checkbox where checkbox value is set as id from the database. How can i access them to controller to update in database. I have tried to dump the value in my controller but it show NULL.
Here is my view:
<form action= "po" method="POST" >
#csrf
<input type="submit" name="submit">
<div class="table-responsive">
<table class="table custom-table">
<thead>
<tr>
<th scope="col">
<label class="control control--checkbox">
<input type="checkbox" class="js-check-all"/>
<div class="control__indicator"></div>
</label>
</th>
<th scope="col" >S.N</th>
<th scope="col">LC NO</th>
<th scope="col">Applicant</th>
<th scope="col">Doc Value</th>
<th scope="col">Doc Received date</th>
<th scope="col">LC Type</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php $number = 1;?>
#foreach($datas as $items)
<tr>
<th scope="row" style="padding:20px">
<label class="control control--checkbox">
<input type="checkbox" name="checkboxlist[]" value="{{$items->id}}" />
<div class="control__indicator"></div>
</label>
</th>
<td>{{$number}}</td>
<td>{{$items->lc_no}}</td>
<td>{{$items->applicant}}</td>
<td>{{$items->doc_value}}</td>
<td>{{$items->rec_date}}</td>
<td>{{$items->sight_usance}}</td>
</tr>
<?php $number++; ?>
#endforeach
</tbody>
</table>
</div>
</form>
Here is my Controller
function po(Request $req){
dd($req->chekboxlist);
}
You are accessing wrong key from Request $req->chekboxlist
But it should be
$req->checkboxlist
Always add Validation to Avoid erorrs while saving data
$validate=Validator::make($request->all(), [
"checkboxlist" => "required|array",
]);
if($validate->fails()){
return redirect()->back()->with("errors",$validate->errors());
}

How to use the data-filter-control-container option on Bootstrap-table?

I'm trying to set-up the new feature from filterControl but maybe I didn't understand how it works. Documentation is telling:
Set to e.g. #filter to allow custom input filter in an element with the id filter. Each filter element (input or select) must have the following id bootstrap-table-filter-control- ( must be replaced with the defined Field name).
My code example is on https://live.bootstrap-table.com/code/joicy/3593
You have to set a selector for the value of data-filter-control-container property.
In your code example, you should try with '#filter' instead of 'true'.
Like that :
data-filter-control-container="#filter">
I've created https://jsfiddle.net/SaeedYasin/k8vqcs9m/41/ to showcase how to use data-filter-control-container property. Here is the HTML,
<div class="container">
<h3>Bootstrap-table</h3>
<div id="filter">
<select class="form-control bootstrap-table-filter-control-name">
<option value=""></option>
</select>
</div>
<table
id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-filter-control="true"
data-filter-control-container="#filter"
>
<thead>
<tr>
<th data-field="id" data-filter-control="select">Id</th>
<th data-field="name" data-filter-control="select">Name</th>
<th data-field="city" data-filter-control="select">City</th>
</tr>
</thead>
</table>
</div>
In this example, name column gets the filter control container, but you can change it to any other column as well. So, instead of bootstrap-table-filter-control-name you can for example, change it to bootstrap-table-filter-control-city to make it work for column "City" instead. Also, you can add an initial value for the option as well, instead of the current empty string.
Would this also work with three filter-controls with filterAlgorithm: 'or'?
What I am interested in creating:
https://jsfiddle.net/p8be45cr/
<div id="filter_type">
<select class="form-control bootstrap-table-filter-control-type">
<option value=""></option>
</select>
</div>
<div id="filter_owner">
<select class="form-control bootstrap-table-filter-control-owner">
<option value=""></option>
</select>
</div>
<div id="filter_status">
<select class="form-control bootstrap-table-filter-control-status">
<option value=""></option>
</select>
</div>
<table
id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-filter-control="true"
data-filter-control-container="#filter_type"
>
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="type">Item type</th>
<th data-field="owner">Owner</th>
<th data-field="value">Item value</th>
<th data-field="status">Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Boat</td>
<td>Kim</td>
<td>1200</td>
<td>Docked</td>
</tr>
<tr>
<td>2</td>
<td>Airplane</td>
<td>John</td>
<td>1400</td>
<td>Flying</td>
</tr>
<tr>
<td>3</td>
<td>Boat</td>
<td>John</td>
<td>1000</td>
<td>Sailing</td>
</tr>
</tbody>
</table>

Can't find element using normalize-space(text())

I'm having problems finding the following element with this xpath //label[normalize-space(text())='F. nacimiento:']
HTML DOM
The green element is the one I want to locate using the previous expression. I was able to find the red element with //label[normalize-space(text())='Servicio Decesos:'] and any other element of the same type.
I tried using //label[text()=' F. nacimiento:'] and works fine, but I'm using a loop and a the pattern //label[normalize-space(text())=' + foobar + '] to identify the rest of element.
My guess is something in that text string has a different char code to a whitespace or something like that, but I have no clue how to check that.
Is there a way to know what normalize-space is returning, in order to use it to id the element?
I have a different pattern to id the elements, but I'm pretty stubborn and this is a good chance to learn something new that could come handy in the future to solve similar issues.
I downloaded the html code as requested:
Here is the red fragment
<div class="sis-frame-bg">
<table class="wideBox" align="center" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<th width="20%" align="right">
<label for="DTRIES_CODZONA">
<span class="sis-important">*</span> Código postal:</label>
</th>
<td><input name="nombdato_CODZONA_1" type="text" id="DTRIES_CODZONA" size="8" maxlength="8" onblur="seccionDecesos();" value="" data-regexp="_codigoPostal" autocomplete="off"></td>
</tr>
<tr>
<th width="20%" align="right">
<label for="DTRIES_SERVICOD">
<span class="sis-important">*</span> Servicio decesos:</label>
</th>
<td>
<select name="nombdato_SERVICOD_1" id="DTRIES_SERVICOD" onchange="seccionDescricionServicio();" data-name="Servicio decesos" data-obligatorio="true" data-regexp="_cadena">
<option selected="selected" value="" title="Elegir"> Elegir</option>
</select>
</td>
</tr>
<tr>
<th colspan="2" align="left">
<div id="datosServicioDecesos">
<!-- ASI261 -->
<!-- ASI261 -->
</div>
</th>
</tr>
</tbody>
</table>
</div>
And the green fragment
<table class="wideBox" cellspacing="0" cellpadding="2" align="center">
<tbody>
<tr>
<th align="right">
<label for="ASEG_FECHNACI">
<span class="sis-important">*</span> F. nacimiento:</label>
</th>
<td>
<input id="ASEG_FECHNACI" name="fechnaci" type="text" maxlength="10" size="12" class="js-popUpCalendar js-dateformat hasDatepicker" onblur="formatoFecha(this);" data-name="FECHA DE NACIMIENTO ASEGURADO" data-obligatorio="true" title="" value="" data-regexp="_fecha" autocomplete="off">
<img class="ui-datepicker-trigger" src="./ico_calendar.png" alt="..." title="...">
</td>
</tr>
</tbody>
</table>
You can use the below xpath.
//label[normalize-space(.)='* F. nacimiento:']
Screenshot

Resources