I need to create a method that compares two or more arrays if the current date is greater than the due date (date_paymentX) that exists in those arrays and returns how many occurrences there are.
Method:
public function payments()
{
$date = date('Y-m-d'); // Retorna 2017-08-09
$services = Service::all()->toArray();
dd($services);
}
dd () displays:
array:2 [▼
0 => array:22 [▼
"id" => 1
"date" => "2017-08-09"
"date_payment1" => "2017-08-01"
"price1" => "500"
"payment1" => "Não"
"date_payment2" => "2017-08-15"
"price2" => "500"
"payment2" => "Não"
"date_payment3" => "2017-08-20"
"price3" => "500"
"payment3" => "Não"
"customer_id" => 1
"created_at" => "2017-08-09 10:52:12"
"updated_at" => "2017-08-09 12:28:31"
]
1 => array:22 [▼
"id" => 2
"date" => "2017-08-09"
"date_payment1" => "2017-08-01"
"price1" => "500"
"payment1" => "Não"
"date_payment2" => "2017-08-15"
"price2" => "500"
"payment2" => "Não"
"date_payment3" => "2017-08-15"
"price3" => "500"
"payment3" => "Não"
"customer_id" => 1
"created_at" => "2017-08-09 12:09:56"
"updated_at" => "2017-08-09 12:29:12"
]
]
In this example there are 2 overdue payments. You would need the method to return this value (2).