搭建轻舟一期门户、后台和统一登录。
让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user