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

Invitation::scopeOfStudentInCourse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
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