Reputation: 119
I have issues by connecting to tables
I have 2 Model
First Model called PodioBorgerNotat with columns in the table called podio_borger_notats
The second Model called PodioBorgerStamark with columns in the table podio_borger_stamarks
I want to make a connection between PodioBorgerNotat and PodioBorgerStamark
so this is what I do in PodioBorgerNotat Model
public function borger()
{
return $this->belongsTo(PodioBorgerStamark::class, 'borger_item_id', 'item_id');
}
Now I want to output the result by executing this output
$borgernotater = PodioBorgerNotat::orderBy('created_at', 'acs')->orderBy('id', 'desc')->with('PodioBorgerStamark')->paginate(10);
This wont work and i get this error messsage
Call to undefined relationship [PodioBorgerStamark] on model [App\PodioBorgerNotat].
Upvotes: 0
Views: 20
Reputation: 2683
Your relation name is borger
:
public function borger(){
...
}
You should call borger
in with()
:
$borgernotater = PodioBorgerNotat
::orderBy('created_at', 'acs')
->orderBy('id', 'desc')
->with('borger')
->paginate(10);
Upvotes: 1