1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Console\Commands; |
4
|
|
|
|
5
|
|
|
use App\Models\Academic_period; |
6
|
|
|
use Illuminate\Console\Command; |
7
|
|
|
use App\Models\Institution_shift; |
8
|
|
|
use App\Http\Controllers\CloneController; |
9
|
|
|
|
10
|
|
|
class cleanConfig extends Command |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The name and signature of the console command. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $signature = 'clean:clone {year}'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The console command description. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Command description'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Create a new command instance. |
28
|
|
|
* |
29
|
|
|
* @return void |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
parent::__construct(); |
34
|
|
|
$this->shifts = new Institution_shift(); |
|
|
|
|
35
|
|
|
$this->academic_period = new Academic_period(); |
|
|
|
|
36
|
|
|
$this->clone = new CloneController(); |
|
|
|
|
37
|
|
|
$this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Execute the console command. |
42
|
|
|
* |
43
|
|
|
* @return mixed |
44
|
|
|
*/ |
45
|
|
|
public function handle() |
46
|
|
|
{ |
47
|
|
|
$this->start_time = microtime(TRUE); |
|
|
|
|
48
|
|
|
$year = $this->argument('year'); |
49
|
|
|
$academicPeriod = $this->academic_period->getAcademicPeriod($year); |
50
|
|
|
$previousAcademicPeriodYear = $academicPeriod->order; |
|
|
|
|
51
|
|
|
$previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
52
|
|
|
|
53
|
|
|
$params = [ |
54
|
|
|
'academic_period' => $academicPeriod, |
55
|
|
|
'previous_academic_period' => $previousAcademicPeriod |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
if($year == '2019' || $year == '2018/19'){ |
59
|
|
|
die('Academic Year 2019 or earlier can`t be deleted'); |
|
|
|
|
60
|
|
|
}else{ |
61
|
|
|
$this->clone->cleanConfig($params); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|