Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
10 / 12
71.43% covered (warning)
71.43%
5 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
PaymentRecord
83.33% covered (warning)
83.33%
10 / 12
71.43% covered (warning)
71.43%
5 / 7
7.23
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
6 / 6
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
 tenant
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 store
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 paidBy
100.00% covered (success)
100.00%
1 / 1
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
 item
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 PaymentRecord extends Model
11{
12    use HasFactory;
13
14    protected $fillable = [
15        'tenant_id', 'store_id', 'influencer_id', 'settlement_id', 'settlement_item_id',
16        'amount', 'status', 'pix_key', 'paid_at', 'paid_by', 'reference', 'notes', 'metadata',
17    ];
18
19    protected function casts(): array
20    {
21        return [
22            'amount' => 'decimal:2',
23            'status' => PaymentStatus::class,
24            'paid_at' => 'datetime',
25            'metadata' => 'array',
26        ];
27    }
28
29    public function influencer(): BelongsTo { return $this->belongsTo(Influencer::class); }
30    public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); }
31    public function store(): BelongsTo { return $this->belongsTo(Store::class); }
32    public function paidBy(): BelongsTo { return $this->belongsTo(User::class, 'paid_by'); }
33    public function settlement(): BelongsTo { return $this->belongsTo(MonthlySettlement::class, 'settlement_id'); }
34    public function item(): BelongsTo { return $this->belongsTo(SettlementItem::class, 'settlement_item_id'); }
35}