runId = $run; } #[Computed] public function run(): BenchmarkRun { $run = BenchmarkRun::where('run_id', $this->runId) ->visibleTo(auth()->user()) ->firstOrFail(); if ($run->isOwnedBy(auth()->user()) && $this->notes === null) { $this->notes = $run->notes; } return $run; } public function saveNotes(): void { $this->authorizeOwner(); $this->validate([ 'notes' => ['nullable', 'string', 'max:65535'], ]); $this->run->fill(['notes' => $this->notes])->save(); Flux::toast(variant: 'success', text: __('Notes saved.')); } public function toggleVisibility(): void { $this->authorizeOwner(); $this->run->fill([ 'visibility' => $this->run->visibility === BenchmarkRun::VISIBILITY_PUBLIC ? BenchmarkRun::VISIBILITY_PRIVATE : BenchmarkRun::VISIBILITY_PUBLIC, ])->save(); Flux::toast(variant: 'success', text: __('Visibility updated.')); } private function authorizeOwner(): void { if (! $this->run->isOwnedBy(auth()->user())) { throw new AuthorizationException; } } }; ?>