@@ -161,6 +161,7 @@ public function isSkipException($exceptionClass): bool
161161 private function logError ($ exception ): void
162162 {
163163 $ date = date (format: 'Y-m-d H:i:s ' );
164+ $ parameters = $ exception ['storage ' ]['PARAMETERS ' ] ?? null ;
164165
165166 $ slack = (new SlackMessage )
166167 ->headerBlock (
@@ -176,7 +177,18 @@ private function logError($exception): void
176177 $ block ->field ("*File:* \n{$ exception ['file ' ]}" )->markdown ();
177178 $ block ->field ("*Line:* \n{$ exception ['line ' ]}" )->markdown ();
178179 $ block ->field ("*Date:* \n{$ date }" )->markdown ();
179- });
180+ })
181+ ->when (
182+ $ parameters !== null ,
183+ fn (SlackMessage $ message ) => $ message
184+ ->sectionBlock (function (SectionBlock $ block ) use ($ parameters ) {
185+ $ encodedParameters = json_encode ($ parameters , JSON_PRETTY_PRINT );
186+
187+ $ block
188+ ->text ("*Payload*: ``` {$ encodedParameters }``` " )
189+ ->markdown ();
190+ })
191+ );
180192
181193 $ url = config ('slack-logging.webhook_url ' );
182194
@@ -211,11 +223,13 @@ private function createExceptionString(array $data): string
211223
212224 public function getUser (): ?array
213225 {
214- /** @var \Illuminate\Contracts\Auth\Authenticatable $user */
215- $ user = auth ()->user ();
226+ if (function_exists ('auth ' ) && auth ()->check ()) {
227+ /** @var \Illuminate\Contracts\Auth\Authenticatable $user */
228+ $ user = auth ()->user ();
216229
217- if ($ user instanceof Model) {
218- return $ user ->toArray ();
230+ if ($ user instanceof Model) {
231+ return $ user ->toArray ();
232+ }
219233 }
220234
221235 return null ;
0 commit comments