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