Skip to content

Commit 6e7306d

Browse files
committed
Update ActionMonitoring.php
1 parent 88bc96e commit 6e7306d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Models/ActionMonitoring.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Binafy\LaravelUserMonitoring\Models;
44

5+
use Binafy\LaravelUserMonitoring\Utills\ActionType;
56
use Illuminate\Database\Eloquent\Model;
67

78
class ActionMonitoring extends Model
@@ -22,21 +23,27 @@ class ActionMonitoring extends Model
2223

2324
# Methods
2425

26+
/**
27+
* Get the type color by action type.
28+
*/
2529
public function getTypeColor(): string
2630
{
2731
return match ($this->action_type) {
28-
'read' => 'blue',
29-
'store' => 'green',
30-
'update' => 'purple',
31-
'delete' => 'red',
32-
'restore' => 'yellow',
33-
'replicate' => 'pink',
32+
ActionType::ACTION_READ => 'blue',
33+
ActionType::ACTION_STORE => 'green',
34+
ActionType::ACTION_UPDATE => 'purple',
35+
ActionType::ACTION_DELETE => 'red',
36+
ActionType::ACTION_RESTORED => 'yellow',
37+
ActionType::ACTION_REPLICATE => 'pink',
3438
default => 'gray',
3539
};
3640
}
3741

3842
# Relations
3943

44+
/**
45+
* Relation one-to-many, User model.
46+
*/
4047
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
4148
{
4249
return $this->belongsTo(

0 commit comments

Comments
 (0)