I have problem laravel relation. I use method with() in my controller and belongsTo in my model. My relation is normaly but if i get parent data this the problems.
my models
public function pekerjaan()
{
return $this->belongsTo('App\Pekerjaan', 'pekerjaan', 'id');
}
This my controller
$data = Anggota::with('pekerjaan')->where('nik',$nik)->first();
return $data;
I want to get column 'nama_pekerjaan' in my relation 'pekerjaan'
if i use return $data->pekerjaan->nama_pekerjaan;
show errors