eager loading in hasmany belongsto relationship

Solutions on MaxInterview for eager loading in hasmany belongsto relationship by the best coders in the world

showing results for - "eager loading in hasmany belongsto relationship"
Elin
27 Sep 2018
1class Post extends Model
2{
3   //in case of belongs to relationship we need to specify foreign key
4    public function user()
5    {
6        return $this->belongsTo(User::class, 'user_id');
7    }
8}
9