1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Models; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
6
|
|
|
|
7
|
|
|
class Institution_class extends Base_Model { |
8
|
|
|
|
9
|
|
|
public const CREATED_AT = 'created'; |
10
|
|
|
public const UPDATED_AT = 'modified'; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The database table used by the model. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $table = 'institution_classes'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Attributes that should be mass-assignable. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected $fillable = ['name', 'no_of_students', 'class_number', 'total_male_students', 'total_female_students', 'staff_id', 'secondary_staff_id', 'institution_shift_id', 'institution_id', 'academic_period_id', 'modified_user_id', 'modified', 'created_user_id', 'created']; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The attributes excluded from the model's JSON form. |
30
|
|
|
* |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
protected $hidden = []; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The attributes that should be casted to native types. |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $casts = []; |
41
|
|
|
|
42
|
|
|
// protected |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The attributes that should be mutated to dates. |
46
|
|
|
* |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
protected $dates = ['modified', 'created']; |
50
|
|
|
|
51
|
|
|
public function class_teacher(){ |
52
|
|
|
return $this->belongsTo('App\Models\Security_group_user','staff_id','security_user_id'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function institution(){ |
56
|
|
|
return $this->belongsTo('App\Models\Institution','institution_id'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function getShiftClasses($shift){ |
61
|
|
|
return self::query() |
62
|
|
|
->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id', |
63
|
|
|
'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id') |
64
|
|
|
->where('institution_shift_id',$shift) |
65
|
|
|
// ->where('academic_period_id',$academicPeriod) |
66
|
|
|
->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id') |
67
|
|
|
->groupBy('institution_classes.id') |
68
|
|
|
->get()->toArray(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public static function getGradeClasses($education_grade_id,$institution_id){ |
72
|
|
|
return self::query() |
73
|
|
|
->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id', |
74
|
|
|
'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id') |
75
|
|
|
->where('institution_class_grades.education_grade_id',$education_grade_id) |
76
|
|
|
->where('institution_classes.institution_id',$institution_id) |
77
|
|
|
->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id') |
78
|
|
|
->get()->toArray(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|