Hello!
I'm having an issue with one of my eager loaded relationship. I'm trying to get a Document and its associated StatsDocument.
If I go
Document::first()->stat;
It works, I get the corresponding StatsDocument object, but if I go
Document::with('stat')->first()->stat;
I get null.
Relation stat is defined as follow in App\Http\Models\Document.php:
public function stat()
{
return $this->hasOne('App\Http\Models\StatsDocument', 'id', 'document_id');
}
I don't get what's wrong, all my other realtionships seem to be working perfectly fine while this one doesn't.
Any help is appreciated, Thank you
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community