feat: rework logging

This commit is contained in:
llama committed 2023-10-11 22:28:14 +11:00
1 parent 87bdbeee05
commit 2d5991988d
15 files changed
+204 -95

No files matched your search

+13 -6
View File
@@ -2,13 +2,13 @@
namespace App\Http\Controllers\Api;
use App\Enums\LogAction;
use App\Http\Controllers\Controller;
use App\Models\Log;
use App\Models\Quote;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class WebHookController extends Controller
{
public function webHookSend(string $payload)
@@ -27,8 +27,12 @@ class WebHookController extends Controller
}
Log::create([
'user_id' => auth()?->user()?->id,
'content' => "Quote sent. {$quote}",
'user_id' => auth()?->user()?->id ?? 1,
'loggable_type' => Quote::class,
'loggable_id' => null,
'action' => LogAction::SEND,
'content' => $quote,
'ip' => request()->ip(),
]);
$this->webHookSend($quote);
@@ -39,9 +43,12 @@ class WebHookController extends Controller
$quote = Quote::inRandomOrder()->first();
Log::create([
'user_id' => auth()?->user()?->id,
'quote_id' => $quote->id,
'content' => 'Quote sent.',
'user_id' => auth()?->user()?->id ?? 1,
'loggable_type' => Quote::class,
'loggable_id' => $quote->id,
'action' => LogAction::REQUEST,
'content' => 'Random quote requested',
'ip' => request()->ip(),
]);
$this->webHookSend($quote->quote);