lagdo /
tontine
| 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
|
|||
| 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 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.