Passed
Push — master ( e2afa6...f12f55 )
by Darko
10:43
created

UserActivity::getColorClassAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class UserActivity extends Model
8
{
9
    const UPDATED_AT = null;
10
11
    protected $fillable = [
12
        'user_id',
13
        'username',
14
        'activity_type',
15
        'description',
16
        'metadata',
17
    ];
18
19
    protected $casts = [
20
        'metadata' => 'array',
21
        'created_at' => 'datetime',
22
    ];
23
24
    /**
25
     * Get icon class based on activity type
26
     */
27
    public function getIconAttribute(): string
28
    {
29
        return match ($this->activity_type) {
30
            'registered' => 'user-plus',
31
            'deleted' => 'user-times',
32
            'role_updated' => 'user-shield',
33
            default => 'info-circle',
34
        };
35
    }
36
37
    /**
38
     * Get color class based on activity type
39
     */
40
    public function getColorClassAttribute(): string
41
    {
42
        return match ($this->activity_type) {
43
            'registered' => 'green',
44
            'deleted' => 'red',
45
            'role_updated' => 'blue',
46
            default => 'gray',
47
        };
48
    }
49
}
50