Skip to content

Commit 5aa3c2f

Browse files
committed
add getTypeColor method to Action model
1 parent 15a9072 commit 5aa3c2f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Models/ActionMonitoring.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ class ActionMonitoring extends Model
2020
*/
2121
protected $guarded = ['id'];
2222

23+
# Methods
24+
25+
public function getTypeColor(): string
26+
{
27+
return match ($this->action_type) {
28+
'read' => 'blue',
29+
'store' => 'green',
30+
'update' => 'purple',
31+
'delete' => 'red',
32+
default => 'gray',
33+
};
34+
}
35+
2336
# Relations
2437

2538
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo

0 commit comments

Comments
 (0)