Passed
Pull Request — develop (#11)
by
unknown
03:48 queued 58s
created

Invitation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A student() 0 3 1
A group() 0 3 1
A scopeOfStudentInCourse() 0 5 1
1
<?php
2
3
namespace App\Judite\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Invitation extends Model
8
{
9
    /**
10
     * Get the student of this invitation.
11
     *
12
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
13
     */
14
    public function student()
15
    {
16
        return $this->belongsTo(Student::class);
17
    }
18
19
    /**
20
     * Get the group of this invitation.
21
     *
22
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
23
     */
24
    public function group()
25
    {
26
        return $this->belongsTo(Group::class);
27
    }
28
29
    /**
30
     * Scope a query to get the student amount of invitations in a given course.
31
     *
32
     * @param \Illuminate\Database\Eloquent\Builder $query
33
     * @param string                                $studentNumber
34
     * @param int                                   $courseId
35
     *
36
     * @return \Illuminate\Database\Eloquent\Builder
37
     */
38
    public function scopeOfStudentInCourse($query, $studentNumber, $courseId)
39
    {
40
        return $query->where([
41
            ['course_id', '=', $courseId],
42
            ['student_number', '=', $studentNumber],
43
            ]);
44
    }
45
}
46