Activity::deleteAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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