Error: Trying to get a property of non-object

0

I'm running the following iteration and getting the error Trying to get property of non-object , the code being:

                    @if(isset($propostas))
                        @foreach($propostas as $p)
                            <tr>
                                <td>{{$p->proposta}}</td>
                                <td>{{$p->descricao}}</td>
                                <td>{{$p->valor}}</td>
                                <td>{{$p->data}}</td>
                                <td>
                                    <button style="border: 0px; background: transparent;" class="ver_proposta" value="{{$p->id}}">
                                        <span class="glyphicon glyphicon-edit"></span>
                                    </button>
                                </td>
                                <td>
                                    <div class="form-group">
                                        <select id="cbx_status" class="form-control">
                                            <option value="Analise" {{$p->status->situacao == "Analise" ? 'selected' : ''}}>Analise</option>
                                            <option value="Aprovado" {{$p->status->situacao == "Aprovado" ? 'selected' : ''}}>Aprovado</option>
                                            <option value="Atualizado" {{$p->status->situacao == "Atualizado" ? 'selected' : ''}}>Atualizado</option>
                                            <option value="Pausado" {{$p->status->situacao == "Pausado" ? 'selected' : ''}}>Pausado</option>
                                            <option value="Finalizado" {{$p->status->situacao == "Finalizado" ? 'selected' : ''}}>Finalizado</option>
                                        </select> 
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    @endif
    
asked by anonymous 26.03.2018 / 18:41

2 answers

0
<select id="cbx_status" class="form-control" name="propostas">
        @foreach($propostas as $p)
          <option @if($p->status->situacao->id == $p->status->situacao->id) selected @endif value="{{$situacao->id}}">{{$situacao->nome}}</option>
        @endforeach
      </select>

Try something like this, I had these problems too.

    
26.03.2018 / 18:49
0

Probably the error is giving in the relationship

  

$ p- > status

Check if all proposal relationships with status are all filled out. This usually happens when the called relationship is null then there is no situation for null status.

$p->status->situacao
    
27.03.2018 / 03:20