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

luttje / filament-user-attributes / 7254443569

18 Dec 2023 10:14PM UTC coverage: 73.72% (-0.2%) from 73.873%
7254443569

push

github

web-flow
Feature/custom config field support (#6)

* refactor so configs related to user attributes can be fetched + better livewire support

* let devs add custom config fields

* remove changelog workflow

43 of 67 new or added lines in 8 files covered. (64.18%)

1 existing line in 1 file now uncovered.

1296 of 1758 relevant lines covered (73.72%)

30.13 hits per line

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

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

3
namespace Luttje\FilamentUserAttributes\Models;
4

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

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

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

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

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

39
    /**
40
     * Gets all user attribute configs with a certain key/value pair in
41
     * the config field.
42
     */
NEW
43
    public static function queryByConfig(string $key, mixed $value)
×
44
    {
NEW
45
        return static::query()
×
NEW
46
            ->whereJsonContains('config', [$key => $value]);
×
47
    }
48

49
    /**
50
     * Gets all user attribute configs with a certain key in the config field.
51
     */
NEW
52
    public static function queryByConfigKey(string $key)
×
53
    {
NEW
54
        return static::query()
×
NEW
55
            ->whereJsonContainsKey('config->[*]->' . $key);
×
56
    }
57
}
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