����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 3.149.249.124 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/www/common/Workspaces/ |
Upload File : |
<?php namespace Common\Workspaces; use App\User; use Arr; use Auth; class ActiveWorkspace { const HEADER = 'Be-Workspace-Id'; /** * @var Workspace|null; */ private $cachedWorkspace; private $memberCache = []; public $id; public function __construct() { $this->id = (int) Arr::get($_COOKIE, $this->cookieName()) ?: null; } public function workspace(): ?Workspace { if (is_null($this->cachedWorkspace)) { $workspaceId = $this->id; $this->cachedWorkspace = $this->personal() ? 0 : Workspace::find($workspaceId) ?? 0; if (!$this->cachedWorkspace) { cookie()->queue( $this->cookieName(), null, -2628000, null, null, null, false, ); } } return $this->cachedWorkspace ?: null; } public function personal(): bool { return !$this->id; } public function owner(): User { return $this->workspace()->owner_id === Auth::id() ? Auth::user() : $this->workspace()->owner; } public function currentUserIsOwner(): bool { if ($this->personal()) { return true; } return $this->workspace() && $this->workspace()->owner_id === Auth::id(); } public function member(int $userId): ?WorkspaceMember { if (!isset($this->memberCache[$userId])) { $this->memberCache[$userId] = app(WorkspaceMember::class) ->where([ 'user_id' => $userId, 'workspace_id' => $this->workspace()->id, ]) ->first(); } return $this->memberCache[$userId]; } private function cookieName(): string { $userId = Auth::id(); return "{$userId}_activeWorkspace"; } }