ErrorException Property [path_foto] does not exist on this collection instance. Laravel 5.4

0

Good morning,

I have the following function in a laravel driver

public function Show ($ id) {

    $configuracion = FrontConfiguracion::find(1);

    $contacto = FrontDatosContacto::find(1);

    $areas = FrontAreas::find($id);

    $funcionarios = FrontTalentoHumano::all()->where('area_id','=',$id);

    return view('front.acerca-entidad.listar-talento-humano', compact('configuracion', 'contacto', 'areas', 'funcionarios'));

}

The problem is that when I go to call the view, I get the following error:

I could see that he recognizes the configuration, contact and area models; but in civil servants it only shows Collection instead of recognizing the model FrontTalentoHumano that is the one that corresponds to him in this case ...

This is how I call the property within list-talent-human.blade.php

I hope you can help me and give me a light, since I have been with this error and the project late for several days.

Thank you!

    
asked by Juan 14.06.2017 в 06:43
source

1 answer

0

in your code, officials is a collection due to

$funcionarios = FrontTalentoHumano::all()->where('area_id','=',$id);

Since I guess there will be several officials in that area, right?

what you have to do in the template is a loop, for example, with foreach:

@foreach ($funcionarios as $funcionario)
    <img src="../{{funcionario->ruta_foto}}">
@endforeach

This way, in every $ official you have one of the elements. This will print several images in a row. You should adapt it to your specific needs.

Check out the blade template engine documentation at link .

Personally I like more twig (because I use symfony) but in some cases it is quite similar.

    
answered by 14.06.2017 / 07:55
source