1 | <?php namespace JackJoe\ActivityLog\Models; |
||
7 | class Activity extends Eloquent { |
||
8 | /** |
||
9 | * The database table used by the model. |
||
10 | * |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $table = 'activity_log'; |
||
14 | |||
15 | /** |
||
16 | * The fillable fields for the model. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $fillable = [ |
||
21 | 'user_id', |
||
22 | 'content', |
||
23 | 'content_id', |
||
24 | 'action', |
||
25 | 'state', |
||
26 | 'details', |
||
27 | 'data', |
||
28 | 'version', |
||
29 | 'ip_address', |
||
30 | 'user_agent', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Get the user that the activity belongs to. |
||
35 | * |
||
36 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
37 | */ |
||
38 | public function user() |
||
42 | |||
43 | /** |
||
44 | * Create an activity log entry. |
||
45 | * |
||
46 | * @param mixed $data |
||
47 | * @return boolean |
||
48 | */ |
||
49 | public static function log($data = []) |
||
106 | } |
||
107 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: