Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
8 / 14
45.45% covered (danger)
45.45%
5 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
Influencer
57.14% covered (warning)
57.14%
8 / 14
45.45% covered (danger)
45.45%
5 / 11
20.52
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
4 / 4
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
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 user
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 coupons
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 activeCoupon
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 orders
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 commissions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 achievements
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 paymentRecords
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 notificationRecipients
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use App\Enums\Status;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8use Illuminate\Database\Eloquent\Relations\BelongsTo;
9use Illuminate\Database\Eloquent\Relations\HasMany;
10use Illuminate\Database\Eloquent\Relations\HasOne;
11
12class Influencer extends Model
13{
14    use HasFactory;
15
16    protected $fillable = [
17        'tenant_id', 'store_id', 'user_id', 'name', 'email', 'instagram', 'tiktok', 'cpf_cnpj',
18        'pix_key', 'base_commission_percentage', 'status', 'internal_notes',
19    ];
20
21    protected function casts(): array
22    {
23        return [
24            'base_commission_percentage' => 'decimal:2',
25            'status' => Status::class,
26        ];
27    }
28
29    public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); }
30    public function store(): BelongsTo { return $this->belongsTo(Store::class); }
31    public function user(): BelongsTo { return $this->belongsTo(User::class); }
32    public function coupons(): HasMany { return $this->hasMany(InfluencerCoupon::class); }
33    public function activeCoupon(): HasOne { return $this->hasOne(InfluencerCoupon::class)->where('status', 'active')->latestOfMany(); }
34    public function orders(): HasMany { return $this->hasMany(Order::class); }
35    public function commissions(): HasMany { return $this->hasMany(Commission::class); }
36    public function achievements(): HasMany { return $this->hasMany(GamificationAchievement::class); }
37    public function paymentRecords(): HasMany { return $this->hasMany(PaymentRecord::class); }
38    public function notificationRecipients(): HasMany { return $this->hasMany(NotificationRecipient::class); }
39}