Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SettlementItem
90.91% covered (success)
90.91%
10 / 11
75.00% covered (warning)
75.00%
3 / 4
4.01
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 settlement
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 influencer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 paidBy
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Models;
4
5use App\Enums\PaymentStatus;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
10class SettlementItem extends Model
11{
12    use HasFactory;
13
14    protected $fillable = [
15        'settlement_id', 'tenant_id', 'store_id', 'influencer_id', 'gross_amount', 'adjustments_amount',
16        'net_amount', 'payment_status', 'paid_at', 'paid_by', 'payment_reference', 'metadata',
17    ];
18
19    protected function casts(): array
20    {
21        return [
22            'gross_amount' => 'decimal:2',
23            'adjustments_amount' => 'decimal:2',
24            'net_amount' => 'decimal:2',
25            'payment_status' => PaymentStatus::class,
26            'paid_at' => 'datetime',
27            'metadata' => 'array',
28        ];
29    }
30
31    public function settlement(): BelongsTo { return $this->belongsTo(MonthlySettlement::class, 'settlement_id'); }
32    public function influencer(): BelongsTo { return $this->belongsTo(Influencer::class); }
33    public function paidBy(): BelongsTo { return $this->belongsTo(User::class, 'paid_by'); }
34}