-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPendingTransaction.php
More file actions
41 lines (34 loc) · 954 Bytes
/
PendingTransaction.php
File metadata and controls
41 lines (34 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Support\Arr;
class PendingTransaction extends Transaction
{
const STATUS_PENDING = 0;
const STATUS_COMPLETE = 1;
const STATUS_CANCELED = 2;
protected $dates = [
'due_date',
];
/**
* @param ScheduledTransaction $scheduledTransaction
*/
public static function generateMonthlyTransactions($scheduledTransaction)
{
foreach ($scheduledTransaction->getMonthlyRecurrences(Carbon::today()) as $recurrence) {
$attributes = Arr::except($scheduledTransaction->toArray(), ['id', 'rrule']);
$attributes['due_date'] = $recurrence;
self::create($attributes);
}
}
public function isCompleted()
{
return $this->status == self::STATUS_CANCELED;
}
public function complete()
{
return $this->update([
'status' => self::STATUS_CANCELED,
]);
}
}