ProfitTransfer::session()   A
last analyzed

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 0
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
use Illuminate\Database\Eloquent\Casts\Attribute;
7
8
use function trans;
9
10
class ProfitTransfer extends Base
11
{
12
    /**
13
     * The table associated with the model.
14
     *
15
     * @var string
16
     */
17
    protected $table = 'v_profit_transfers';
18
19
    /**
20
     * Indicates if the model should be timestamped.
21
     *
22
     * @var bool
23
     */
24
    public $timestamps = false;
25
26
    public function fund()
27
    {
28
        return $this->belongsTo(Fund::class);
29
    }
30
31
    public function session()
32
    {
33
        return $this->belongsTo(Session::class);
34
    }
35
36
    public function member()
37
    {
38
        return $this->belongsTo(Member::class);
39
    }
40
41
    public function type(): Attribute
42
    {
43
        return Attribute::make(
44
            get: fn() => trans($this->coef > 0 ?
0 ignored issues
show
Bug introduced by
The property coef does not seem to exist on Siak\Tontine\Model\ProfitTransfer. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
45
                'meeting.labels.saving' : 'meeting.labels.settlement'),
46
        );
47
    }
48
49
    /**
50
     * @param  Builder  $query
51
     * @param  Fund  $fund
52
     *
53
     * @return Builder
54
     */
55
    public function scopeWhereFund(Builder $query, Fund $fund): Builder
56
    {
57
        return $query->where('fund_id', $fund->id);
58
    }
59
60
    /**
61
     * @param  Builder  $query
62
     * @param  Session  $session
63
     *
64
     * @return Builder
65
     */
66
    public function scopeWhereSession(Builder $query, Session $session): Builder
67
    {
68
        return $query->where('session_id', $session->id);
69
    }
70
}
71