Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

534
Vistas
Attempt to read property "title" on bool when trying to load a single post

I'm trying to load a single blog post in laravel, but every time I click on a single post, I get the error 'Attempt to read property "title" on bool.' I've tried looking up the error but I haven't found a solution and don't know what causes the error. Here's my code

Blade file:

@foreach($AboutUs as $about_us)
    <div class="col-lg">
        <img src="images/agenda.png" class="img-fluid shadow-lg" style="">
        <p class="mt-3 text-success fw-bold fs-5 text-lg-start">{{$about_us->title}}</p>
        <p class="fs-6 text-lg-start"> {{$about_us->description}}</p>
        <p class="text-success fw-bold text-lg-start"><a href="/about.show/{{$about_us->id}}" class="text-success text-decoration-none">{{$about_us->button}}</a></p>
        <!--<img src="images/hr-2.png" class="img-fluid float-start my-2">-->
    </div>
@endforeach

Controller:

public function show($id)
{
    $data = AboutUs::find($id);
    return view('about.show', ['AboutUs' => $data])
        ->with(['AboutUs' => AboutUs::find($id)]);
}

Routes:

Route::get('/about.show/{id}', 'App\Http\Controllers\WelcomeController@show')->name('about.show');

Can anyone offer any assistance?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

OK, it's a bit of a mess, to be honest.

The short answer is that :

$data = AboutUs::find($id);

is returning one item, not a collection of items. You can't loop through that like you're trying to do, hence the error.

For some reason, though, you're then loading that again with when you're returning your view?

return view('about.show',['AboutUs'=>$data])->with(['AboutUs' => AboutUs::find($id),]);

So, for starters, you can probably simplify that - assuming you're wanting to load a post, in your controller you can then instead :

public function show($id) {
   $post = AboutUs::find($id);
   return view('about.show')->with(compact('post');
}

But then in your blade file you're trying to loop through your $AboutUs variable as though it's a collection, but it's not - find($id) returns a single model instance.

So naturally Blade is getting a bit confused.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda