Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added filament multitenancy support for media picker #377

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Components/Modals/CuratorPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class CuratorPanel extends Component implements HasForms, HasActions

public bool $isLimitedToDirectory = false;

public bool $isTenantAware = false;

public bool $isMultiple = false;

public ?int $maxItems = null;
Expand Down Expand Up @@ -113,6 +115,7 @@ public function openModal(string $id, array $settings = []): void
$this->imageResizeTargetWidth = $settings['imageResizeTargetWidth'];
$this->imageResizeTargetHeight = $settings['imageResizeTargetHeight'];
$this->isLimitedToDirectory = $settings['isLimitedToDirectory'];
$this->isTenantAware = $settings['isTenantAware'];
$this->isMultiple = $settings['isMultiple'];
$this->maxItems = $settings['maxItems'];
$this->maxSize = $settings['maxSize'];
Expand Down Expand Up @@ -172,6 +175,9 @@ public function form(Form $form): Form
public function getFiles(int $page = 0, bool $excludeSelected = false): array
{
$files = App::make(Media::class)->query()
->when(filament()->hasTenancy(), function ($query) {
return $query->where(filament()->getTenantOwnershipRelationshipName().'_id',filament()->getTenant()->id);
})
->when($this->selected, function ($query, $selected) {
$selected = collect($selected)->pluck('id')->toArray();

Expand Down
Loading