1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\ActivityHistory; |
9: | |
10: | use Aurora\Modules\ActivityHistory\Models\ActivityHistory; |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | class Manager extends \Aurora\System\Managers\AbstractManager |
20: | { |
21: | public function __construct(\Aurora\System\Module\AbstractModule $oModule = null) |
22: | { |
23: | parent::__construct($oModule); |
24: | } |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | public function Create($UserId, $ResourceType, $ResourceId, $IpAddress, $Action, $Time, $GuestPublicId) |
37: | { |
38: | return ActivityHistory::create([ |
39: | 'UserId' => $UserId, |
40: | 'ResourceType' => $ResourceType, |
41: | 'ResourceId' => $ResourceId, |
42: | 'IpAddress' => $IpAddress, |
43: | 'Action' => $Action, |
44: | 'Timestamp' => $Time, |
45: | 'GuestPublicId' => $GuestPublicId |
46: | ]); |
47: | } |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | public function GetListByUserId($UserId) |
55: | { |
56: | return ActivityHistory::where('UserId', $UserId)->get(); |
57: | } |
58: | |
59: | public function DeleteActivityHistory($iId) |
60: | { |
61: | $bResult = false; |
62: | |
63: | try { |
64: | $bResult = !!ActivityHistory::find($iId)->delete(); |
65: | } catch (\Aurora\System\Exceptions\BaseException $oException) { |
66: | $this->setLastException($oException); |
67: | } |
68: | |
69: | return $bResult; |
70: | } |
71: | |
72: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | public function GetList($UserId, $ResourceType, $ResourceId, $Offset, $Limit) |
82: | { |
83: | $oQuery = ActivityHistory::where([ |
84: | ['UserId', '=', $UserId], |
85: | ['ResourceType', '=', $ResourceType], |
86: | ['ResourceId', '=', $ResourceId], |
87: | ]); |
88: | if ($Offset > 0) { |
89: | $oQuery = $oQuery->offset($Offset); |
90: | } |
91: | if ($Limit > 0) { |
92: | $oQuery = $oQuery->limit($Limit); |
93: | } |
94: | return $oQuery->get(); |
95: | } |
96: | |
97: | |
98: | |
99: | |
100: | |
101: | |
102: | |
103: | |
104: | public function GetListCount($UserId, $ResourceType, $ResourceId) |
105: | { |
106: | return ActivityHistory::where([ |
107: | ['UserId', '=', $UserId], |
108: | ['ResourceType', '=', $ResourceType], |
109: | ['ResourceId', '=', $ResourceId], |
110: | ])->count(); |
111: | } |
112: | |
113: | public function Delete($UserId, $ResourceType, $ResourceId) |
114: | { |
115: | return ActivityHistory::where([ |
116: | ['UserId', '=', $UserId], |
117: | ['ResourceType', '=', $ResourceType], |
118: | ['ResourceId', '=', $ResourceId], |
119: | ])->delete(); |
120: | } |
121: | } |
122: | |