-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAppServiceProvider.php
More file actions
41 lines (36 loc) · 1.27 KB
/
AppServiceProvider.php
File metadata and controls
41 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Providers;
use App\Http\Curl\CurlRequest;
use App\Http\Curl\HttpRequest;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Register any application services.
*/
public function register(): void {
$this->app->bind(HttpRequest::class, CurlRequest::class);
}
/**
* Bootstrap any application services.
*/
public function boot(): void {
Queue::failing(function (JobFailed $event): void {
$name = data_get($event->job->payload(), 'data.commandName');
$wrappedException = new \Exception("Executing Job '$name' failed.", 1, $event->exception);
report($wrappedException);
});
// Local-only SQL query logging for debugging
if ($this->app->environment('local')) {
\Event::listen(QueryExecuted::class, function (QueryExecuted $query) {
\Log::debug('Query Executed: ', [
'sql' => $query->sql,
'bindings' => $query->bindings,
'connection' => $query->connectionName,
]);
});
}
}
}