Passed
Push — main ( 3c3a9e...751c63 )
by Thierry
05:41
created

ProfitTransfer::scopeWhereSession()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Siak\Tontine\Model;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
class ProfitTransfer extends Base
8
{
9
    /**
10
     * The table associated with the model.
11
     *
12
     * @var string
13
     */
14
    protected $table = 'v_profit_transfers';
15
16
    /**
17
     * Indicates if the model should be timestamped.
18
     *
19
     * @var bool
20
     */
21
    public $timestamps = false;
22
23
    public function fund()
24
    {
25
        return $this->belongsTo(Fund::class);
26
    }
27
28
    public function session()
29
    {
30
        return $this->belongsTo(Session::class);
31
    }
32
33
    public function member()
34
    {
35
        return $this->belongsTo(Member::class);
36
    }
37
38
    /**
39
     * @param  Builder  $query
40
     * @param  Fund  $fund
41
     *
42
     * @return Builder
43
     */
44
    public function scopeWhereFund(Builder $query, Fund $fund): Builder
45
    {
46
        return $query->where('fund_id', $fund->id);
47
    }
48
49
    /**
50
     * @param  Builder  $query
51
     * @param  Session  $session
52
     *
53
     * @return Builder
54
     */
55
    public function scopeWhereSession(Builder $query, Session $session): Builder
56
    {
57
        return $query->where('session_id', $session->id);
58
    }
59
}
60