@@ -111,13 +111,15 @@ public function isAdmin()
111111 *
112112 * @return bool
113113 */
114- public static function isAssignedAgent ($ id )
114+ public function isAssignedAgent ($ id )
115115 {
116- if (auth ()-> check () && auth ()-> user () ->panichd_agent ) {
117- if (auth ()-> user () ->id == Ticket::find ($ id )->agent ->id ) {
116+ if ($ this ->panichd_agent ) {
117+ if ($ this ->id == Ticket::find ($ id )->agent ->id ) {
118118 return true ;
119119 }
120120 }
121+
122+ return false ;
121123 }
122124
123125 /**
@@ -127,13 +129,13 @@ public static function isAssignedAgent($id)
127129 *
128130 * @return bool
129131 */
130- public static function isTicketOwner ($ id )
132+ public function isTicketOwner ($ id )
131133 {
132- if (auth ()->check ()) {
133- if (auth ()->user ()->id == Ticket::find ($ id )->user_id ) {
134- return true ;
135- }
134+ if ($ this ->id == Ticket::find ($ id )->user_id ) {
135+ return true ;
136136 }
137+
138+ return false ;
137139 }
138140
139141 /**
@@ -143,11 +145,8 @@ public static function isTicketOwner($id)
143145 *
144146 * @return int
145147 */
146- public static function maxLevel ()
148+ public function maxLevel ()
147149 {
148- if (!auth ()->check ()) {
149- return 0 ;
150- }
151150 $ member = \PanicHDMember::find (auth ()->user ()->id );
152151 if ($ member ->isAdmin ()) {
153152 return 3 ;
@@ -165,11 +164,8 @@ public static function maxLevel()
165164 *
166165 * @return int
167166 */
168- public static function currentLevel ()
167+ public function currentLevel ()
169168 {
170- if (!auth ()->check ()) {
171- return 0 ;
172- }
173169 $ member = \PanicHDMember::find (auth ()->user ()->id );
174170 if ($ member ->isAdmin ()) {
175171 return 3 ;
@@ -217,11 +213,8 @@ public function levelInCategory($id = false)
217213 *
218214 * @return bool
219215 */
220- public static function canCloseTicket ($ id )
216+ public function canCloseTicket ($ id )
221217 {
222- if (!auth ()->check ()) {
223- return false ;
224- }
225218 $ member = \PanicHDMember::find (auth ()->user ()->id );
226219
227220 $ a_perm = Setting::grab ('close_ticket_perm ' );
@@ -249,12 +242,8 @@ public static function canCloseTicket($id)
249242 *
250243 * @return bool
251244 */
252- public static function canCommentTicket ($ ticket )
245+ public function canCommentTicket ($ ticket )
253246 {
254- if (!auth ()->check ()) {
255- return false ;
256- }
257-
258247 if (\PanicHDMember::canManageTicket ($ ticket ->id )
259248 or \PanicHDMember::isTicketOwner ($ ticket ->id )
260249 or $ ticket ->commentNotifications ()->where ('member_id ' , auth ()->user ()->id )->count () > 0 ) {
@@ -271,15 +260,13 @@ public static function canCommentTicket($ticket)
271260 *
272261 * @return bool
273262 */
274- public static function canManageTicket ($ id )
263+ public function canManageTicket ($ id )
275264 {
276- if (!auth ()->check ()) {
277- return false ;
278- }
279265 $ member = \PanicHDMember::find (auth ()->user ()->id );
280266
281267 if ($ member ->isAdmin ()) {
282268 return true ;
269+
283270 } elseif ($ ticket = Ticket::find ($ id )) {
284271 if ($ member ->id == $ ticket ->agent_id or (Setting::grab ('agent_restrict ' ) == 0 and $ member ->categories ()->where ('id ' , $ ticket ->category_id )->count () == 1 )) {
285272 return true ;
@@ -296,11 +283,8 @@ public static function canManageTicket($id)
296283 *
297284 * @return bool
298285 */
299- public static function canViewNewTickets ()
286+ public function canViewNewTickets ()
300287 {
301- if (!auth ()->check ()) {
302- return false ;
303- }
304288 $ member = \PanicHDMember::find (auth ()->user ()->id );
305289
306290 if ($ member ->isAdmin ()) {
0 commit comments