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

luttje / filament-user-attributes / 45240180363

23 Nov 2026 06:36PM UTC coverage: 81.169% (+4.4%) from 76.786%
45240180363

push

github

luttje
Mention unsaved configs reaching the policy in the upgrade guide

2250 of 2772 relevant lines covered (81.17%)

26.9 hits per line

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

25.0
/src/Models/UserAttributeConfig.php
1
<?php
2

3
namespace Luttje\FilamentUserAttributes\Models;
4

5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
7
use Illuminate\Database\Eloquent\Model;
8

9
/**
10
 * @property string $owner_type
11
 * @property string $owner_id
12
 * @property string $resource_type
13
 * @property string $model_type
14
 * @property array $config
15
 */
16
class UserAttributeConfig extends Model
17
{
18
    protected $fillable = [
19
        'owner_type',
20
        'owner_id',
21
        'resource_type',
22
        'model_type',
23
        'config',
24
    ];
25

26
    protected $casts = [
27
        'config' => AsArrayObject::class,
28
    ];
29

30
    public function owner()
24 ✔
31
    {
32
        return $this->morphTo(__FUNCTION__, 'owner_type', 'owner_id');
24 ✔
33
    }
34

35
    public function userAttributes()
×
36
    {
37
        return $this->hasMany(UserAttribute::class, 'model_type', 'model_type');
×
38
    }
39

40
    /**
41
     * Limits to user attribute configs with a certain key/value pair in
42
     * the config field. Can be chained, e.g. onto `$owner->userAttributesConfigs()`.
43
     */
44
    public function scopeQueryByConfig(Builder $query, string $key, mixed $value): void
×
45
    {
46
        $query->whereJsonContains('config', [$key => $value]);
×
47
    }
48

49
    /**
50
     * Limits to user attribute configs with a certain key in the config field.
51
     * Can be chained, e.g. onto `$owner->userAttributesConfigs()`.
52
     */
53
    public function scopeQueryByConfigKey(Builder $query, string $key): void
×
54
    {
55
        $query->whereJsonContainsKey('config->[*]->' . $key);
×
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc