让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。 Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
698 B
PHP
26 lines
698 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\AuditLog;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
abstract class Controller
|
|
{
|
|
protected function ok(mixed $data = null, string $message = 'ok', int $status = 200): JsonResponse
|
|
{
|
|
return response()->json(['message' => $message, 'data' => $data], $status);
|
|
}
|
|
|
|
protected function audit($actor, string $action, ?object $model, string $summary): void
|
|
{
|
|
AuditLog::query()->create([
|
|
'actor_id' => $actor?->id,
|
|
'action' => $action,
|
|
'subject_type' => $model ? $model::class : null,
|
|
'subject_id' => $model->id ?? null,
|
|
'summary' => $summary,
|
|
]);
|
|
}
|
|
}
|