1], ['content' => ''] ); $this->content = $clipboard->content ?? ''; $this->lastSyncedContent = $this->content; } public function updatedContent(): void { SharedClipBoard::where('id', 1)->update([ 'content' => $this->content, ]); $this->lastSyncedContent = $this->content; } public function refreshSharedContent(): void { $sharedContent = SharedClipBoard::find(1)?->content ?? ''; // Do not overwrite text that this user is editing. if ( $this->content === $this->lastSyncedContent && $sharedContent !== $this->lastSyncedContent ) { $this->content = $sharedContent; $this->lastSyncedContent = $sharedContent; } } public function clearContent(): void { SharedClipBoard::where('id', 1)->update([ 'content' => '', ]); $this->content = ''; $this->lastSyncedContent = ''; } public static function canAccess(): bool { // return Auth::check() && Auth::user()->can('view shared clipboard page'); $user = Auth::user(); if(Auth::check() && !Auth::user()->can('view shared clipboard page')) { if (!$user) { return false; } $configuration = Configuration::where('c_group', 'Shared Clip Board')->where('c_value', $user->name)->first(); return $configuration ? true:false; } else{ return Auth::check() && Auth::user()->can('view shared clipboard page'); } } }