you need to use whereHas
for filter data from relationship
table assume you have set plan
as relationship
function inside Product
model so you code will be like this
$results = Product::where('name', 'like', '%'. $request->input('search-product-name'). '%')
->whereHas("plan", function ($q) use ($request) {
$q->where('name', 'like', '%'. $request->input('search-product-plan'). '%');
})->get();
ref link https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence
CLICK HERE to find out more related problems solutions.