4
I’m trying to get the type of the columns of the tables of my BD, and how to use PHP with the Laravel I tried to use the GetType to pick up the guys and show on view. But the code is only returning Object.
Follows the code:
Controller
$input = $request->all();
$tables = $request->input('tables');
$resultados = DB::select('select * from ' .$tables);
$colunas = array();
foreach($resultados as $resultado){
    echo (getType($resultado));
    $colunas[] = ((array)$resultado);
}
dd($colunas);
View
<div class="form-group">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
        {!! Form::label('tables', 'Tabelas:', ['class' => 'control-label']) !!}
        <br><br>
            <select class="selectpicker form-control" name="tables" id="tables">
                <option disabled selected> -- Selecione -- </option>
                    @foreach($tables as $table)
                        @foreach ($table as $key => $value)
                            <option value="{{ $value }}">{{ $value }}</option>
                        @endforeach
                     @endforeach
            </select>
    </div>
Is there any other way to get the guy?
you need the types that are in your Bank table? what comes in
$tables(is the name of a table)?– novic
What comes in
$tablesare the columns of the table I select in my database. What I need now is to get the type of each column. Ex: int, varchar.– Lara Gallassi
A
DESC tabelawouldn’t solve? will list the name, type and options (Primary key, null allows, default value etc) of column.– rray
Lara
O que vem em $tables sãos as colunas da tabelame cite examples that comes within this variable?– novic
Virgilio, my
tabelaflameTabelas, inside of her I have:Id,tabela,campo,tipoandpesquisa. And I want to take the type of each field. Got it? And Rray, I don’t know if DESC table would solve because I didn’t try. I’ll try.– Lara Gallassi
Now I understand Lara, because, your code with a s in the end caused me confusion, well the answer I believe answers what you need, please take a look
– novic