mardi 5 novembre 2019

please fix the error of trying to get property of non-object

Here is the code and it shows "trying to get property 'price' of non-object. Help me fix this please. There is data in $doc and it is not empty.

   @foreach ($reports as $report)
                        <tr>
                            <td></a></td>
                            <td></td>
                            @if($report->book_date== null || ($report->book_date != null && ($report->release_date != null && $report->release_date < date('Y-m-d'))))
                            <td class="text-danger"><strong>Vacant</strong></td>
                            <td></td>
                            <td>---</td>
                            <td></td>
                            @endif
                            @if($report->book_date != null && ( $report->release_date ==null || $report->release_date >= date('Y-m-d')))
                                @php 
                                    $doc = DB::table('gen_resident_room')
                                        ->Join('sales_pipeline', 'gen_resident_room.person_id', '=', 'sales_pipeline.id')
                                        ->where([['room_id',$report->room_id]])->first();

                                        if(isset($doc->pros_name)) {
                                         $n = explode (",",$doc->pros_name);

                                        }
                                @endphp
                                @if(isset($doc) && isset($doc->stage) && $doc->stage === "MoveIn")
                                    <td class="text-success"><b>Occupied</b></td>
                                @else
                                    <td class="text-success"><b>Booked</b></td>
                                @endif
                                <td></td>
                                <td></td>
                                <td>  </td>
                            @endif
                        </tr>
                        @endforeach

Aucun commentaire:

Enregistrer un commentaire