1 | <?php |
||
12 | class RenewTraining extends Command |
||
13 | { |
||
14 | /** |
||
15 | * The number of days to renew a training before it expires. |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $offset = 14; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * List of all renewed notes. |
||
24 | * |
||
25 | * @var Collection |
||
26 | */ |
||
27 | protected $trainingAdminRecord; |
||
28 | |||
29 | /** |
||
30 | * The name and signature of the console command. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $signature = 'training:renew'; |
||
35 | |||
36 | /** |
||
37 | * The console command description. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $description = 'Renews training before it expires.'; |
||
42 | |||
43 | /** |
||
44 | * Create a new command instance. |
||
45 | */ |
||
46 | public function __construct() |
||
51 | |||
52 | /** |
||
53 | * Execute the console command. |
||
54 | * |
||
55 | * @return RenewTraining |
||
56 | */ |
||
57 | public function handle() |
||
76 | |||
77 | public function getList() |
||
78 | { |
||
79 | return $this->trainingAdminRecord->sortBy('userFullName'); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Check if training note has been renewed already. |
||
84 | * |
||
85 | * @param $trainingUser |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | private function renewedAlready($trainingUser) |
||
102 | |||
103 | /** |
||
104 | * Check if the training is past the renews_in value. |
||
105 | * |
||
106 | * @param $trainingUser |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | private function timeToRenew($trainingUser) |
||
124 | |||
125 | /** |
||
126 | * Generate a new Training note that will be due $this->offset days from now. |
||
127 | * |
||
128 | * @param $trainingUser |
||
129 | */ |
||
130 | private function processRenewal($trainingUser) |
||
147 | |||
148 | /** |
||
149 | * @param $trainingUser |
||
150 | * @param Carbon $dueDate |
||
151 | * |
||
152 | * @return TrainingUser |
||
153 | */ |
||
154 | private function createRecord($trainingUser, $dueDate) |
||
166 | } |
||
167 |