feat(admin): improve payments and server settings

This commit is contained in:
baodev0
2026-10-19 07:59:23 +07:00
parent 9ed77a85fd
commit ea9a53f742
32 changed files with 680 additions and 78 deletions
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Jobs\Mail\Admin;
use App\Mail\Admin\AdminPaymentReceived;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
class AdminPaymentReceivedJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $timeout = 60;
public function __construct(public readonly array $data) {}
public function handle(): void
{
$setting = Setting::where('key', 'setting')->first();
$values = $setting ? json_decode((string) $setting->value, true) : [];
$adminEmail = $values['admin_email'] ?? null;
if (!$adminEmail) {
Log::warning('AdminPaymentReceivedJob: admin_email not configured in settings.');
return;
}
try {
Mail::to($adminEmail)->send(new AdminPaymentReceived([
...$this->data,
'company_name' => $values['company'] ?? config('app.name'),
]));
} catch (\Throwable $e) {
Log::error('AdminPaymentReceivedJob: failed to send email.', [
'reference' => $this->data['reference'] ?? null,
'error' => $e->getMessage(),
]);
}
}
}