class User extends Authenticatable
{
public function comments()
{
return $this->hasMany(Comment::class);
}
}
class Comment extends Model
{
public function user()
{
return $this->belongsTo(User::class);
}
}
class CommentController extends BaseController
{
public function index()
{
return Comment::with('user')->get();
}
}