File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,22 +26,22 @@ public static function boot()
2626 /**
2727 * The created event for the model is listened to and the logs are created.
2828 */
29- if ( auth ()-> user () ) {
30- static :: created ( function ( $ model ) {
29+ static :: created ( function ( $ model ) {
30+ if ( auth ()-> check () ) {
3131 $ model ->logs ()->create ([
3232 'action ' => 'Create ' ,
3333 'ip_address ' => request ()->ip (),
3434 'device ' => request ()->userAgent (),
3535 'user_id ' => auth ()->user ()->id
3636 ]);
37- });
38- }
37+ }
38+ });
3939
4040 /**
4141 * The updated event for the model is listened to and the logs are created.
4242 */
43- if ( auth ()-> user () ) {
44- static :: updated ( function ( $ model ) {
43+ static :: updated ( function ( $ model ) {
44+ if ( auth ()-> check () ) {
4545 $ model ->logs ()->create ([
4646 'action ' => 'Update ' ,
4747 'ip_address ' => request ()->ip (),
@@ -50,22 +50,23 @@ public static function boot()
5050 'old_data ' => json_encode ($ model ->getRawOriginal ()),
5151 'changed_values ' => json_encode ($ model ->getChanges ())
5252 ]);
53- });
54- }
53+ }
54+ });
5555
5656 /**
5757 * The deleted event for the model is listened to and the logs are created.
5858 */
59- if ( auth ()-> user () ) {
60- static :: deleted ( function ( $ model ) {
59+ static :: deleted ( function ( $ model ) {
60+ if ( auth ()-> check () ) {
6161 $ model ->logs ()->create ([
6262 'action ' => 'Delete ' ,
6363 'ip_address ' => request ()->ip (),
6464 'device ' => request ()->userAgent (),
6565 'user_id ' => auth ()->user ()->id
6666 ]);
67- });
68- }
67+ }
68+ });
69+
6970
7071 }
7172
You can’t perform that action at this time.
0 commit comments