Model: Record (id,user_id, status_id, date, note, timestamp)
class Record extends Model { function status(){ return $this->belongsTo('App\SmokingStatus','status_id'); } }
Model: Status(id,name)
class Status extends Model { function record() { return $this->hasMany('App\Record','id','status_id'); } }
If you try to access it directly like this {{$record->status->name }} it will return “Trying to get property of non-object”.
You need to access the user status value like this in view
{{ @$record->status->name }} or {{ $record->status['name'] }}