Laravel 7: Problems with request in registration form - php

Hello i have a problem with the registration in laravel.
In my register.blade.php there's a table that the user fills with a js function.
When i click on submit button i need to fetch datas from that table but i don't have a key mapping the table in the $request variable
That's the part of the code where i put the table:
<table class="table align-content-center" id="compList" name="compList">
<thead>
<tr>
<th scope="col">Competence</th>
<th scope="col">Level</th>
<th scope="col">Remove</th>
</tr>
</thead>
</table>

You should use form attribute to fetch data from it.
You can rewrite this part code as follows :
<form name="compList" class="table align-content-center" id="compList">
<thead>
<tr>
<th scope="col">Competence</th>
<th scope="col">Level</th>
<th scope="col">Remove</th>
</tr>
</thead>
</form>

Related

How to filter a dynamic table in Laravel 9 by variable "type"?

I am trying to filter a dynamic table in Laravel 9 by variable "type" but I don't know the value of the type because it is inserted automatically by the user.
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>IdPp</th>
<th>Name</th>
<th>Type</th>
<th>Position</th>
</tr>
</thead>
<tbody>
#foreach($parts as $part)
<tr>
<th>{{$part->id}}</th>
<th>{{$part->Name}}</th>
<th>{{$part->type->intituléTypePP}}</th>
<th>{{$part->position->intituléPositionP}}</th>
</tr>
#endforeach
</tbody>
</table>

Laravel: get checkbox value from html table

I have a blade page with a html table where any row has a checkbox, all these rows have a key value. I need all these checkbox values and update a table. At the moment I have this solution, but it seems not the best choice.
<table class="table table-sm table-striped table-bordered" style="width: 100%;">
<thead class="thead-light">
<tr>
<th >ARRIVED</th>
<th >Cron.</th>
<th >NAME</th>
</tr>
</thead>
<tbody>
{{$counter=1}}
#foreach($data as $row)
<tr>
<td><input type="checkbox" name="arrived_yes_no_{{$counter}}"></td>
<td>{{$row->Crono}}</td>
<td>{{$row->Name}}</td>
</tr>
{{$counter++}}
#endforeach
</tbody>
</table>
I will rename any checkbox with the _$counter suffix so when I send via post all the page content I can (I hope) retrive all the checkbox values.
Is there a better option?
#Virginia has the right idea. Changing the checkbox names to array syntax keyed by the ID of the row will make it much easier to work with server side.
// checkbox names
name="arrived_yes_no[{{ $row->id }}]"

I am sorting data on database but webpage doesn't take effect

I tried to sort/order data on database. I used this command:
SELECT * FROM `estates`
ORDER BY `estates`.`price` ASC
It take effect on database order. But on webpage it doesn't. How can I make it take effect on webpage too? Any idea? Thank you.
By the way I am using Laravel,
and retriving data from database with MVC
If you need to check to my page structure here it is:
<table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
<thead>
<tr>
<th width="150px">会社名</th>
<th width="150px">物件名</th>
<th width="250px">住所</th>
<th width="150px">販売価格</th>
<th width="100px">総戸数</th>
<th width="150px">専有面積</th>
<th width="100px">間取り</th>
<th width="100px">バルコニー面積</th>
<th width="100px">竣工時期</th>
<th width="100px">入居時期</th>
</tr>
<thead>
<tbody>
#foreach($estates as $estate)
<tr class="even">
<td>{{$estate->company_name}}</td>
<td>{{$estate->name}}<br/></td>
<td>{{$estate->address}}</td>
<td>{{$estate->price}}</td>
<td>{{$estate->hows_old}}</td>
<td>{{$estate->extend}}</td>
<td>{{$estate->rooms}}</td>
<td>{{$estate->balcon_m2}}</td>
<td>{{$estate->old}}</td>
<td>{{$estate->entery}}</td>
</tr>
#endforeach
</tbody>
</table>
And here is the controller:
public function sumos()
{
$estates = Estates::get();
//test
$data['estates'] = $estates;
return view('welcome', $data);
}
try to use orderBy
Estates::orderBy('price')->get();

Laravel Has Many Through Only brings first record

Well that is my problem.
This is the public function in my model
public function traerDesc(){
return $this->hasManyThrough('App\modeloDescripcionVehiculos', 'App\modeloVehiculos', 'idDescripcion', 'id', 'idVehiculo');
}
This is the controller call
$data = [
'venta' => modeloAccion::where('accion', 'venta')->with('traerVehiculo', 'traerUsuario', 'traerCliente', 'traerTransaccion', 'traerVenta', 'traerDesc')->get(),
];
return view('modulos.general.informes')->with($data);
This is my table in the blade file
<table class="table table-striped table-bordered table-hover" id="myTable">
<thead>
<tr>
<th class="text-center">Vehiculo vendido</th>
<th class="text-center">Precio de compra</th>
<th class="text-center">Precio de venta</th>
<th class="text-center">Ganancia %</th>
<th class="text-center">Usuario</th>
<th class="text-center">Cliente</th>
<th class="text-center">Fecha venta</th>
</tr>
</thead>
<tbody>
#foreach($venta as $ventas)
<tr class="text-center">
#foreach($ventas->traerDesc as $descripcion)
<td>{{$descripcion->marca}}</td>
#endforeach
<td>{{$ventas->traerVehiculo->precioCompra}}</td>
<td>{{$ventas->traerVehiculo->precioVenta}}</td>
<td>asd</td>
<td>{{$ventas->traerUsuario->nombre.' '.$ventas->traerUsuario->apellidoPaterno.' '.$ventas->traerUsuario->apellidoMaterno}}</td>
<td>asd</td>
<td>{{date('d-m-Y', strtotime($ventas->traerVenta->fechaVenta))}}</td>
</tr>
#endforeach
</tbody>
</table>
This is my table accion. As you can see . It has 3 rows where accion = venta and all of them has the same info in all the tables. But it only brings the first row rejecting the others
And the view shows only 1 marca that would be like brand in english.
Hope can make myself clear enough. Thank you
Not sure it will help, but you use eager loading method with wrong way.
Right using is:
Model::with(relations)->where(condition)->get();
Or
Model::where(condition)->get()->load(relations);

Parsing an HTML page in Wordpress and PHP, how do I select a specific table?

Parsing an HTML page in Wordpress and PHP, how do I select a specific table?
Right now, I request a specific page, and I am able to return the "body" section with my code.
However, I'd like to only return the "myTable" fragment.:
<table id="myTable" class="display" table width="60%" border="1">
My code:
$response = wp_remote_get( $request_url );
return $response['body'];
HTML looks similar to this:
<html>
…
<body>
<table id="myTable" class="display" table width="60%" border="1">
<thead>
<tr>
<th>Number </th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>123456789101112</td>
<td>Foobar makes the best foo I ever barred!</td>
</tr>
</tbody>
</table>
</body>
</html>

Categories