2
People I have a problem to list certain results of a database using Arabic, and I have tried everything to elaborate a logic to list these results and I can not elaborate this logic.
I have a table called Payments, that table lists certain payouts of a relationship with another table called Campaign, that is, the payments table are payments made for a particular campaign.
I have a model called Campaign where I have a function that makes this relationship looking for results that have status = 3, which in case are payment approved.
public function success_payments(){
return $this->hasMany(Payment::class)->whereStatus('3');
}
This function returns results from the Payment table that have the status = 3 field, and this table has one more field called updated_at of the timestamp type, and that’s where my problem is, i need to include in this query a condition that returns me results where the current date is >= the field updated_at + 30 days, ie I need to add 30 days to the value of the field updated_at and then check if the current date is >= a variable that has this field added 30 days, or if there is another way of doing so.
Why this condition.
This current query returns payment made for certain campaign that have the status = 3 field, which in case is payment confirmed, that is, it returns all payments that have been confirmed, but I use the pagseguro as payment gatway and the same, in my case, only release payments 30 days after confirmation.
That’s why I need to show the owners of these campaigns only the payments that have already been confirmed and that 30 days have passed.
If anyone can give me a strength please immensely.
Thanks for the reply Jedson, I hadn’t thought about that you said, because the status may change a few times even after it is changed to 3, this field is the only one that changes because there is an update, Now I’m kind of wondering how to implement this logic to return these payments correctly. You told me to guess a field with the payment date, could you tell me what logic would look like in this case ?
– Rafael