am asking after many trials of achieving what am about to ask i have two arrays the first one is array of offers with is_checked status true or false like this
[
{
id:24,
name:"Discount 50",
discount_amount:"50.00",
discount_type:"price",
start_date:"2021-05-06",
end_date:"2021-05-07",
is_checked:true,
enabled:1
},
{
id:22,
name:"Discount 40",
discount_amount:"40.00",
discount_type:"price",
start_date:"2021-05-07",
end_date:"2021-05-10",
is_checked:false,
enabled:1
}
]
then i have a another array of objects that represent days according to specific period start_date and end_date
like the following
[
{
id:1,
offer_id:24,
date:"2021-05-06",
date_name:"Thursday",
discount_type:"price",
discount_amount:"50.00"
},
{
id:2,
offer_id:22,
date:"2021-05-07",
date_name:"Friday",
discount_type:"price",
discount_amount:"50.00"
},
{
id:3,
offer_id:22,
date:"2021-05-08",
date_name:"Saturday",
discount_type:"price",
discount_amount:"50.00"
}
]
What i need to achieve in simple words from the first array as you can see the offer with id 24 the is_checked status of it is set to true then in the second array which has an offer_id matches the checked id i need to attach another key called also is_checked so the result became like this
[
{
id:1,
offer_id:24,
date:"2021-05-06",
date_name:"Thursday",
discount_type:"price",
discount_amount:"50.00",
is_checked:true,
},
{
id:2,
offer_id:22,
date:"2021-05-07",
date_name:"Friday",
discount_type:"price",
discount_amount:"50.00",
is_checked:false,
},
{
id:3,
offer_id:22,
date:"2021-05-08",
date_name:"Saturday",
discount_type:"price",
discount_amount:"50.00",
is_checked:false,
}
]
and sorry if the description was too long