I know this has been asked before but specific to my case I could't find an answer that worked.
Currently I have two models. App\JobStatus App\Customer
In model App\JobStatus I have this:
public function customer()
{
return $this->belongsTo('App\Customer');
}
In model App\Customer I have this:
public function jobs()
{
return $this->hasMany('App\JobStatus', 'customer_id');
}
'customer_id' is the foreign key. I then try to access customer from Jobstatus in my controller like so:
$testMePlease = JobStatus::first()->where('qb', '=', 1);
$testMePlease->customer;
I have attempted to dd this. To put it in foreach loop. I've also tried $testMePlease->customer->customer_name. Customer_name being a column in the table and I get back the same error: "Undefined property: Illuminate\Database\Eloquent\Builder::$customer"
Any ideas what I'm doing wrong?