Skip to content

Commit 79da69a

Browse files
Refactor Plunk service registration and improve email sending logic
1 parent d91e1e6 commit 79da69a

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

InstaRepas/app/Providers/AppServiceProvider.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ class AppServiceProvider extends ServiceProvider
1515
*/
1616
public function register(): void
1717
{
18-
// Enregistrer le service Plunk dans le conteneur
19-
$this->app->singleton(PlunkService::class, function ($app) {
20-
return new PlunkService();
21-
});
18+
$this->app->singleton(PlunkService::class, function ($app) {
19+
return new PlunkService();
20+
});
2221
}
2322

2423
/**
2524
* Bootstrap any application services.
2625
*/
2726
public function boot(): void
2827
{
29-
if (config('app.env') === 'production') {
30-
URL::forceScheme('https');
28+
if (config('app.env') === 'production') {
29+
URL::forceScheme('https');
3130
}
32-
// Enregistrer le transport Plunk
33-
Mail::extend('plunk', function ($app) {
34-
return new PlunkTransport($app->make(PlunkService::class));
31+
32+
// Corriger l'enregistrement du transport Plunk
33+
Mail::extend('plunk', function ($config) {
34+
return new PlunkTransport(app(PlunkService::class));
3535
});
3636
}
37-
}
37+
}

InstaRepas/app/Services/PlunkService.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ public function __construct()
1919
public function sendEmail($to, $subject, $body, $options = [])
2020
{
2121
try {
22-
// Construction du payload de base
2322
$payload = [
2423
'to' => $to,
2524
'subject' => $subject,
2625
'body' => $body,
2726
];
2827

29-
// Ajout des options supplémentaires si présentes
3028
if (isset($options['from'])) {
3129
$payload['from'] = $options['from'];
3230
}
@@ -47,13 +45,11 @@ public function sendEmail($to, $subject, $body, $options = [])
4745
$payload['headers'] = $options['headers'];
4846
}
4947

50-
// Envoi de la requête à l'API Plunk
5148
$response = Http::withHeaders([
5249
'Authorization' => 'Bearer ' . $this->apiKey,
5350
'Content-Type' => 'application/json',
5451
])->post($this->baseUrl . '/send', $payload);
5552

56-
// Traitement de la réponse
5753
if ($response->successful()) {
5854
return $response->json();
5955
} else {

InstaRepas/config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727

2828
'plunk' => [
29-
'api_key' => env('PLUNK_API_KEY'),
29+
'api_key' => env('PLUNK_API_KEY'),
3030
],
3131

3232
'ses' => [

0 commit comments

Comments
 (0)