In Product.php
public function reviews(){
return $this->hasMany(Review::class);
}
In Review.php
public function product(){
return $this->belongsTo(Product::class);
}
public function user(){
return $this->belongsTo(User::class);
}
In User.php
public function reviews(){
return $this->hasMany(Review::class);
}
in controller
$product = Product::where('slug', $request->slug)->with('category')->with('reviews.user')->first();
in Blade
{{$review->user->name}}
Now In blade it returns null.
mention that review table has product_id, reviewed_by
Now, How Can I get Reviewers Name from this relationship Models? Please Help me with this one.