mardi 5 novembre 2019

Trying to get property of non-object. How to resolve it?

Trying to get property 'stage' of non-object. How do I resolve this error? I tried various methods also checked that $doc 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($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


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire