@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class LogActivityJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
public int $backoff = 5;
|
||||
|
||||
public function __construct(private readonly array $payload) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
ActivityLog::create($this->payload);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Jobs\LogActivityJob;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -29,7 +29,7 @@ class ActivityLogger
|
||||
try {
|
||||
[$causerType, $causerId, $causerName] = $this->resolveCauser();
|
||||
|
||||
ActivityLog::create([
|
||||
LogActivityJob::dispatch([
|
||||
'log_name' => $logName,
|
||||
'event' => $event,
|
||||
'description' => $description,
|
||||
@@ -44,7 +44,7 @@ class ActivityLogger
|
||||
'user_agent' => request()->userAgent(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('[ActivityLogger] Failed to write log', [
|
||||
Log::warning('[ActivityLogger] Failed to dispatch log job', [
|
||||
'error' => $e->getMessage(),
|
||||
'event' => $event,
|
||||
'log_name' => $logName,
|
||||
|
||||
@@ -45,6 +45,15 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
|
||||
Route::prefix('v1')
|
||||
->group(function () {
|
||||
Route::get('/debug-customers', function () {
|
||||
$customers = \App\Models\Customer::orderByDesc('created_at')
|
||||
->limit(5)
|
||||
->get(['id', 'uuid', 'fullname', 'email', 'total', 'created_at']);
|
||||
|
||||
return response()->json($customers);
|
||||
});
|
||||
})
|
||||
->group(function () {
|
||||
// Invoice Test — Send invoice email with PDF attachment
|
||||
Route::prefix('invoice-test')
|
||||
|
||||
Reference in New Issue
Block a user