Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

523
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!