Security_group_institution   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A institution() 0 2 1
A security_group() 0 2 1
A institution_classes() 0 6 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Security_group_institution extends Model  {
8
9
10
    /**
11
     * The database table used by the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'security_group_institutions';
16
17
    /**
18
     * Attributes that should be mass-assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable = ['security_group_id', 'institution_id', 'created_user_id', 'created'];
23
24
    /**
25
     * The attributes excluded from the model's JSON form.
26
     *
27
     * @var array
28
     */
29
    protected $hidden = [];
30
31
    /**
32
     * The attributes that should be casted to native types.
33
     *
34
     * @var array
35
     */
36
    protected $casts = [];
37
38
    /**
39
     * The attributes that should be mutated to dates.
40
     *
41
     * @var array
42
     */
43
    protected $dates = ['modified', 'created', 'created', 'created'];
44
45
46
47
    public function institution(){
48
        return $this->belongsTo('App\Models\Institution','institution_id');
49
    }
50
51
    public function institution_classes(){
52
        return $this->hasMany('App\Models\Institution_class','institution_id','institution_id')
53
        ->select('institution_classes.*')
54
        ->join('academic_periods', function($query){
55
            $query->on('institution_classes.academic_period_id','academic_periods.id');
56
            $query->whereIn('academic_periods.code',['2020','2019/2020']);
57
        });
58
    }
59
60
    public function security_group(){
61
        return $this->belongsTo('App\Models\Security_group','security_group_id');
62
    }
63
64
}