LibreBill::member()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Siak\Tontine\Model;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Support\Collection;
7
8
class LibreBill extends Base
9
{
10
    /**
11
     * Indicates if the model should be timestamped.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    public function session()
18
    {
19
        return $this->belongsTo(Session::class);
20
    }
21
22
    public function charge()
23
    {
24
        return $this->belongsTo(Charge::class);
25
    }
26
27
    public function member()
28
    {
29
        return $this->belongsTo(Member::class);
30
    }
31
32
    public function bill()
33
    {
34
        return $this->belongsTo(Bill::class);
35
    }
36
37
    /**
38
     * @param  Builder  $query
39
     * @param  Session  $session
40
     *
41
     * @return Builder
42
     */
43
    public function scopeWhereSession(Builder $query, Session $session): Builder
44
    {
45
        return $query->where('session_id', $session->id);
46
    }
47
48
    /**
49
     * @param  Builder  $query
50
     * @param  Charge  $charge
51
     *
52
     * @return Builder
53
     */
54
    public function scopeWhereCharge(Builder $query, Charge $charge): Builder
55
    {
56
        return $query->where('charge_id', $charge->id);
57
    }
58
59
    /**
60
     * @param  Builder  $query
61
     * @param  Collection  $members
62
     *
63
     * @return Builder
64
     */
65
    public function scopeWhereMembers(Builder $query, Collection $members): Builder
66
    {
67
        return $query->whereIn('member_id', $members);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->whereIn('member_id', $members) could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
68
    }
69
}
70