mirror of
https://github.com/pelican-dev/panel.git
synced 2026-07-16 05:53:54 +03:00
Switch inserts to proper creates (#1190)
* Switch inserts to proper creates * Push `$token` to `$tokens[]` in `ToggleTwoFactorService` --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
@@ -5,10 +5,8 @@ namespace App\Http\Controllers\Api\Remote;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\User;
|
||||
use Webmozart\Assert\Assert;
|
||||
use App\Models\Server;
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\ActivityLogSubject;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\Remote\ActivityEventRequest;
|
||||
|
||||
@@ -71,19 +69,17 @@ class ActivityProcessingController extends Controller
|
||||
}
|
||||
|
||||
foreach ($logs as $key => $data) {
|
||||
Assert::isInstanceOf($server = $servers->get($key), Server::class);
|
||||
$server = $servers->get($key);
|
||||
assert($server instanceof Server);
|
||||
|
||||
$batch = [];
|
||||
foreach ($data as $datum) {
|
||||
$id = ActivityLog::insertGetId($datum);
|
||||
$batch[] = [
|
||||
'activity_log_id' => $id,
|
||||
/** @var ActivityLog $activityLog */
|
||||
$activityLog = ActivityLog::forceCreate($datum);
|
||||
$activityLog->subjects()->create([
|
||||
'subject_id' => $server->id,
|
||||
'subject_type' => $server->getMorphClass(),
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
ActivityLogSubject::insert($batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user