2
I need to search a database through a view (Laravel Blade). The data obtained, stored in an array, need to display on the page called the database. I am not succeeding in returning the array with such data, because I don’t know how to handle the array within the view block waiting for this answer.
Explain:
The view that prepares the database query has a form, with a Submit button. This action triggers a Controller method that goes to the database, searches the data and returns an array. The data exists, the array is populated. Are the following steps:
First, the view and the form. Filename: listar.blade.php:
@extends ('PrincipalView')
@corpo
<form name="frmTSPesquisar"
action="{{ action('TSController@pesquisarExecutar') }}"
method="GET" role="form">
Busca: <input list="files" placeholder="20000">
<datalist id="files">
<option>20000</option>
</datalist>
<button type="submit">Pesquisar</button>
</form>
@stop
Note that the form Action tag already forwards what Submit will cause.
On the Tscontroller.php page, where the triggered method resides, I have the code:
public function pesquisarExecutar(Request $request) {
$resultado=DB::table('tabts')
->join('tabfiles', 'tabts.file_tabfiles', '=', 'tabfiles.id')
->where('tabfiles.file',"=",$request->input('namSelNumFile'))
->get();
}//pesquisarExecutar
In this above method, how could you make the array $outworking could be used on the same page (list.blade.php) original, below the form that caused this data collection?
The structure of this array $outworking could complete the code with the form in some way like this:
@extends ('PrincipalView')
@corpo
<form name="frmTSPesquisar"
action="{{ action('TSController@pesquisarExecutar') }}" method="GET" role="form">
Busca: <input list="files" placeholder="20000">
<datalist id="files">
<option>20000</option>
</datalist>
<button type="submit">Pesquisar</button>
</form>
@stop
{{-- abaixo seria o que eu preciso para interagir com a resposta via array --}}
@foreach ($resultado as $r)
{{r$->datalancamento}}
@endforeach
Anyway, my problem is, I believe, how to pass the array to the view and, once in this view, how to loop to take advantage of each value obtained within the array.
You can do it with requests via AJAX (js) . Avoid "reloading" pages and form.
– Fernando Herique Rubim Pioli