disk(config('tables.default_filesystem_disk')); } public function disk(string | Closure | null $disk): static { $this->disk = $disk; return $this; } public function height(int | string | Closure | null $height): static { $this->height = $height; return $this; } public function circular(bool | Closure $condition = true): static { $this->isCircular = $condition; return $this; } /** * @deprecated Use `circular()` instead. */ public function rounded(bool | Closure $condition = true): static { return $this->circular($condition); } public function square(bool | Closure $condition = true): static { $this->isSquare = $condition; return $this; } public function size(int | string | Closure $size): static { $this->width($size); $this->height($size); return $this; } public function visibility(string | Closure $visibility): static { $this->visibility = $visibility; return $this; } public function width(int | string | Closure | null $width): static { $this->width = $width; return $this; } public function getDisk(): Filesystem { return Storage::disk($this->getDiskName()); } public function getDiskName(): string { return $this->evaluate($this->disk) ?? config('tables.default_filesystem_disk'); } public function getHeight(): ?string { $height = $this->evaluate($this->height); if ($height === null) { return null; } if (is_int($height)) { return "{$height}px"; } return $height; } public function defaultImageUrl(string | Closure | null $url): static { $this->defaultImageUrl = $url; return $this; } public function getImagePath(): ?string { $state = $this->getState(); if (! $state) { return $this->getDefaultImageUrl(); } if (filter_var($state, FILTER_VALIDATE_URL) !== false) { return $state; } /** @var FilesystemAdapter $storage */ $storage = $this->getDisk(); try { if (! $storage->exists($state)) { return null; } } catch (UnableToCheckFileExistence $exception) { return null; } if ($this->getVisibility() === 'private') { try { return $storage->temporaryUrl( $state, now()->addMinutes(5), ); } catch (Throwable $exception) { // This driver does not support creating temporary URLs. } } return $storage->url($state); } public function getDefaultImageUrl(): ?string { return $this->evaluate($this->defaultImageUrl); } public function getVisibility(): string { return $this->evaluate($this->visibility); } public function getWidth(): ?string { $width = $this->evaluate($this->width); if ($width === null) { return null; } if (is_int($width)) { return "{$width}px"; } return $width; } public function isCircular(): bool { return $this->evaluate($this->isCircular); } /** * @deprecated Use `isCircular()` instead. */ public function isRounded(): bool { return $this->isCircular(); } public function isSquare(): bool { return $this->evaluate($this->isSquare); } public function extraImgAttributes(array | Closure $attributes, bool $merge = false): static { if ($merge) { $this->extraImgAttributes[] = $attributes; } else { $this->extraImgAttributes = [$attributes]; } return $this; } public function getExtraImgAttributes(): array { $temporaryAttributeBag = new ComponentAttributeBag(); foreach ($this->extraImgAttributes as $extraImgAttributes) { $temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraImgAttributes)); } return $temporaryAttributeBag->getAttributes(); } public function getExtraImgAttributeBag(): ComponentAttributeBag { return new ComponentAttributeBag($this->getExtraImgAttributes()); } }