I am having two tables in my database presented as follow.
offers
ref_id
name
features
id
offer_id
name
What I am trying to do is to retrieve the various offers, for a given set of features.
So I try using the following code but I am not getting the results expected:
$offers = Feature::find(['1', '2', '3'])->offers;
For instance:features with the id of 1 and 2 belongs to offer 1.
feature 3 belongs to offer 3.
From the code above, I am want $offers to contain only two elements offer 1 and 2
I try using the code below but the offers are duplicated:
$offers = DB::table('features')
->whereIn('features.id', ['1', '2', '3'])
->join('offers', 'offers.id', '=', 'features.offer_id')
->get();
kindly help me solve the problem.