|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Log; |
|
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
7
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
|
8
|
|
|
|
|
9
|
|
|
class Institution_student_admission extends Base_Model |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
use SoftDeletes; |
|
13
|
|
|
|
|
14
|
|
|
public const CREATED_AT = 'created'; |
|
15
|
|
|
|
|
16
|
|
|
public const UPDATED_AT = 'modified'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* The database table used by the model. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $table = 'institution_student_admission'; |
|
24
|
|
|
|
|
25
|
|
|
protected $softDelete = true; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Attributes that should be mass-assignable. |
|
29
|
|
|
* |
|
30
|
|
|
* @var array |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $fillable = ['start_date', 'end_date', 'student_id', 'status_id', 'assignee_id', 'institution_id', 'academic_period_id', 'education_grade_id', 'institution_class_id', 'comment', 'modified_user_id', 'modified', 'created_user_id', 'created', 'admission_id']; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* The attributes excluded from the model's JSON form. |
|
36
|
|
|
* |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $hidden = []; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* The attributes that should be casted to native types. |
|
43
|
|
|
* |
|
44
|
|
|
* @var array |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $casts = []; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* The attributes that should be mutated to dates. |
|
50
|
|
|
* |
|
51
|
|
|
* @var array |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $dates = ['modified', 'created', 'modified', 'created', 'start_date', 'end_date', 'modified', 'created']; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Create new Institution student admission from examination data |
|
57
|
|
|
* |
|
58
|
|
|
* @param [type] $student |
|
|
|
|
|
|
59
|
|
|
* @param [type] $admissionInfo |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
public static function createExaminationData($student, $admissionInfo) |
|
63
|
|
|
{ |
|
64
|
|
|
try { |
|
65
|
|
|
$data = [ |
|
66
|
|
|
'start_date' => $admissionInfo['academic_period']->start_date, |
|
67
|
|
|
'start_year' => $admissionInfo['academic_period']->start_year, |
|
68
|
|
|
'end_date' => $admissionInfo['academic_period']->end_date, |
|
69
|
|
|
'end_year' => $admissionInfo['academic_period']->end_year, |
|
70
|
|
|
'student_id' => $student['id'], |
|
71
|
|
|
'status_id' => 124, |
|
72
|
|
|
'institution_id' => $admissionInfo['instituion']->id, |
|
73
|
|
|
'academic_period_id' => $admissionInfo['academic_period']->id, |
|
74
|
|
|
'education_grade_id' => $admissionInfo['education_grade']->id, |
|
75
|
|
|
'institution_class_id' => (($admissionInfo['instituion_class'] != []) && (count($admissionInfo['instituion_class'])==1)) ? $admissionInfo['instituion_class']['id'] : null, |
|
76
|
|
|
'comment' => 'Imported From Examination Data', |
|
77
|
|
|
'updated_from' => 'doe', |
|
78
|
|
|
'created_user_id' => 1 |
|
79
|
|
|
]; |
|
80
|
|
|
self::create($data); |
|
81
|
|
|
} catch (\Throwable $th) { |
|
82
|
|
|
Log::error($th); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public static function createAdmission($studentId,$row,$params,$file){ |
|
87
|
|
|
self::create([ |
|
88
|
|
|
'start_date' => $row['start_date_yyyy_mm_dd'], |
|
89
|
|
|
'start_year' => $row['start_date_yyyy_mm_dd']->format('Y'), |
|
90
|
|
|
'end_date' => $params['academic_period']->end_date, |
|
91
|
|
|
'end_year' => $params['academic_period']->end_year, |
|
92
|
|
|
'student_id' => $studentId, |
|
93
|
|
|
'status_id' => 124, |
|
94
|
|
|
'assignee_id' => $params['assignee_id'], |
|
95
|
|
|
'institution_id' => $params['institution'], |
|
96
|
|
|
'academic_period_id' => $params['academic_period']->id, |
|
97
|
|
|
'education_grade_id' => $params['institution_grade']->education_grade_id, |
|
98
|
|
|
'institution_class_id' => $params['institution_class']->id, |
|
99
|
|
|
'comment' => 'Imported using bulk data upload', |
|
100
|
|
|
'admission_id' => $row['admission_no'], |
|
101
|
|
|
'created_user_id' => $file['security_user_id'] |
|
102
|
|
|
]); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|