Activity   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 65
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDates() 0 4 1
A setUpdatedAtAttribute() 0 4 1
A setContextAttribute() 0 4 1
A getContextAttribute() 0 4 1
A deleteAll() 0 4 1
1
<?php
2
3
namespace JeroenG\ActivityLogger;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * This is the activity model.
9
 *
10
 * @author 	JeroenG
11
 **/
12
class Activity extends Model
13
{
14
    /**
15
     * The database table used by the model.
16
     *
17
     * @var string
18
     */
19
    protected $table = 'activities';
20
21
    /**
22
     * This fields may not be filled.
23
     *
24
     * @var array
25
     */
26
    protected $guarded = ['id'];
27
28
    /**
29
     * Let Eloquent only use the created_at column.
30
     *
31
     * @return array
32
     */
33
    public function getDates()
34
    {
35
        return ['created_at'];
36
    }
37
38
    /**
39
     * Let Eloquent only use the created_at column.
40
     *
41
     * @return null
42
     */
43
    public function setUpdatedAtAttribute($value)
44
    {
45
        // Do nothing.
46
    }
47
48
    /**
49
     * Encode the context array into json.
50
     *
51
     * @return array
52
     */
53
    public function setContextAttribute($value)
54
    {
55
        $this->attributes['context'] = json_encode($value);
56
    }
57
58
    /**
59
     * Decode the context into an array.
60
     *
61
     * @return array
62
     */
63
    public function getContextAttribute($value)
64
    {
65
        return json_decode($value);
66
    }
67
68
    /**
69
     * Delete all logs (not way back!).
70
     * @return void
71
     */
72
    public static function deleteAll()
73
    {
74
        return \DB::table('activities')->delete();
75
    }
76
}
77