Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Attempt to read property "ticket_title" on bool

I have this problem when I want to open specific page by id.

now I am trying to shown title on my page with specific id, which have post in db, but that error stopped me.

there are my code.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

route

Route::get('/tickets/{id}',  [TicketsController::class, 'show'])->name('tickets.show');

controller

 public function show($id) {

        $tickets = Tickets::with('companies')->get();

        $ticketscomp = Companies::with('tickets')->get();

        $severities = Severities::with('tickets')->get();

        $ticketspage = Tickets::findOrFail($id);

 

 return view('tickets.chat', compact('ticketspage'))->with(['tickets'=> $tickets])->with(['ticketscomp'=>$ticketscomp])->with(['severities'=>$severities])->with(['ticketspage'=>$ticketspage]);
    
 //dd($ticketspage->toArray());


blade.php

 @foreach ($ticketspage as $item)
 
  <h6 class="mb-1; ticket-list-title;">{{ $item->ticket_title }}</h6>
     @endforeach

When I dd post. post is opening by id with included information.

This is dd

>Solution :

::findOrFail() returns a single model instance. You do not need a @foreach() loop.

<h6 class="mb-1; ticket-list-title;">{{ $ticketspage->ticket_title }}</h6>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading