Images in databases and Laravel 5.6

0

Good evening I have been working with Laravel 5.6, and they gave me the task of making a query to the database that is postgresql and showing the result in a view. The problem is that in the data consulted there is a field where images are stored and this is in byte format, and when trying to pass the data to the view laravel responds to me:     Type is not supported

this is the code I have in the controller:

public function Datosfull($id,$gestion){
        $Datofuncionario = DB::connection($gestion)->table('funcionario')
                  ->select('id_funcionario','nombre','apellido','celular','fecha_ingreso')
                    ->where('id_funcionario','=',$id)
                    ->first();
       $fotografia = DB::connection($gestion)->table('fotografia')
                    ->select('id_tipo_fotografia','nombre')
                    ->where('id_funcionario','=',$Datofuncionario->id_funcionario) ->get();
return view('inspector.funcionario',compact('Datofuncionario','fotografia')); 

How I have to make these data visible and that the photographs are decoded and can be viewed.

Thank you very much.

    
asked by ALVARO ROBERTO BACARREZA ARZAB 18.10.2018 в 02:24
source

1 answer

0

By using pg_unescape_bytea you could convert your bytea to string, like this:

$tipo_string = pg_unescape_bytea($bytea);

However, as you have it now, keep in mind that in $ Datofuncionario you get an array and in $ fotografia a collection.

The variable $ tipo_string is what you would see:

return view('inspector.funcionario',compact('tipo_string')); 

In the view, another conversion:

{{ htmlspecialchars($tipo_string)}};
    
answered by 19.10.2018 в 17:32