File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -334,20 +334,18 @@ public function mounts()
334334 }
335335
336336 /**
337- * Saves an audit entry to the database for the server.
337+ * Returns a fresh AuditLog model for the server. This model is not saved to the
338+ * database when created, so it is up to the caller to correctly store it as needed.
338339 *
339340 * @param string $action
340341 * @param array $metadata
341342 * @return \Pterodactyl\Models\AuditLog
342343 */
343- public function newAuditEvent (string $ action , array $ metadata ): AuditLog
344+ public function newAuditEvent (string $ action , array $ metadata = [] ): AuditLog
344345 {
345- $ model = AuditLog::factory ($ action , $ metadata )->fill ([
346+ return AuditLog::factory ($ action , $ metadata )->fill ([
346347 'server_id ' => $ this ->id ,
347348 ]);
348- $ model ->save ();
349-
350- return $ model ;
351349 }
352350
353351 /**
@@ -366,9 +364,8 @@ public function newAuditEvent(string $action, array $metadata): AuditLog
366364 */
367365 public function audit (string $ action , Closure $ callback )
368366 {
369- $ model = $ this ->newAuditEvent ($ action , []);
370-
371- return $ this ->getConnection ()->transaction (function () use ($ callback , &$ model ) {
367+ return $ this ->getConnection ()->transaction (function () use ($ action , $ callback ) {
368+ $ model = $ this ->newAuditEvent ($ action );
372369 $ response = $ callback ($ model , $ this );
373370 $ model ->save ();
374371
You can’t perform that action at this time.
0 commit comments