• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LeTraceurSnorkLibrary / MessSaga / 24455793340

15 Apr 2026 12:57PM UTC coverage: 39.248% (+2.7%) from 36.562%
24455793340

Pull #20

github

web-flow
Merge 4e3783ced into 4ac78237e
Pull Request #20: feat: tariffs

161 of 280 new or added lines in 14 files covered. (57.5%)

2 existing lines in 2 files now uncovered.

741 of 1888 relevant lines covered (39.25%)

0.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/app/Models/User.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Models;
6

7
// use Illuminate\Contracts\Auth\MustVerifyEmail;
8
use App\Enums\UserRoleEnum;
9
use App\Tariffs\Contracts\TariffInterface;
10
use App\Tariffs\TariffCatalog;
11
use Database\Factories\UserFactory;
12
use Filament\Models\Contracts\FilamentUser;
13
use Filament\Panel;
14
use Illuminate\Database\Eloquent\Factories\HasFactory;
15
use Illuminate\Database\Eloquent\Relations\HasMany;
16
use Illuminate\Foundation\Auth\User as Authenticatable;
17
use Illuminate\Notifications\Notifiable;
18

19
class User extends Authenticatable implements FilamentUser
20
{
21
    /**
22
     * @use HasFactory<UserFactory>
23
     */
24
    use HasFactory;
25
    use Notifiable;
26

27
    /**
28
     * The attributes that are mass assignable.
29
     *
30
     * @var list<string>
31
     */
32
    protected $fillable = [
33
        'name',
34
        'email',
35
        'password',
36
        'role',
37
        'tariff_code',
38
        'encryption_salt',
39
    ];
40

41
    /**
42
     * The attributes that should be hidden for serialization.
43
     *
44
     * @var list<string>
45
     */
46
    protected $hidden = [
47
        'encryption_salt',
48
        'password',
49
        'remember_token',
50
    ];
51

52
    /**
53
     * @param string $role
54
     *
55
     * @return bool
56
     */
57
    public function hasRole(string $role): bool
58
    {
59
        return $this->role === $role;
6✔
60
    }
61

62
    /**
63
     * @param string $role
64
     *
65
     * @return self
66
     */
67
    public function assignRole(string $role): self
68
    {
69
        $this->role = $role;
1✔
70

71
        return $this;
1✔
72
    }
73

74
    /**
75
     * @param Panel $panel
76
     *
77
     * @return bool
78
     */
79
    public function canAccessPanel(Panel $panel): bool
80
    {
81
        return $this->hasRole(UserRoleEnum::ADMIN->value) || $this->hasRole(UserRoleEnum::MANAGER->value);
5✔
82
    }
83

84
    /**
85
     * @return HasMany<MessengerAccount, $this>
86
     */
87
    public function messengerAccounts(): HasMany
88
    {
89
        return $this->hasMany(MessengerAccount::class);
1✔
90
    }
91

92
    /**
93
     * @return TariffInterface
94
     */
95
    public function tariff(): TariffInterface
96
    {
NEW
97
        return TariffCatalog::forCode($this->tariff_code);
×
98
    }
99

100
    /**
101
     * Boot the model.
102
     *
103
     * @return void
104
     */
105
    protected static function boot(): void
106
    {
107
        parent::boot();
×
108

109
        static::creating(function (User $user): void {
×
110
            if (empty($user->encryption_salt)) {
×
111
                $user->encryption_salt = base64_encode(random_bytes(32));
×
112
            }
113
        });
×
114
    }
115

116
    /**
117
     * Get the attributes that should be cast.
118
     *
119
     * @return array<string, string>
120
     */
121
    protected function casts(): array
122
    {
123
        return [
×
124
            'email_verified_at' => 'datetime',
×
125
            'password'          => 'hashed',
×
126
        ];
×
127
    }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc