Monday, February 27, 2017

Error in Relationship of tables

Im having a error when i try to get some data between 2 tables using eloquent. The error that is giving me is:
Error:
Trying to get property of non-object (View: 

This is my app information
DB:
survey:
- id;
- template_id;
- title;


templates:
- id;
- name;
- internal_name;

SurveyModel:
 public function theme(){

        return $this->hasOne(Template::class, 'template_id','id');
}


View:

@foreach($surveys->reverse() as $survey)

        <tr>
        <td></td>

</tr>
@endforeach



via Pedro

Advertisement