diff --git a/src/Resources/LibraryItemResource.php b/src/Resources/LibraryItemResource.php index 5fd5549..c494a2b 100644 --- a/src/Resources/LibraryItemResource.php +++ b/src/Resources/LibraryItemResource.php @@ -181,6 +181,18 @@ public static function table(Table $table): Table }) ->icon(fn (?LibraryItem $record): string => $record?->getDisplayIcon() ?? 'heroicon-o-document') ->iconPosition('before') + ->description(function (?LibraryItem $record): ?string { + $user = auth()->user(); + if (! $user || ! $record) { + return null; + } + + if ($record->created_by !== $user->id && $record->permissions()->where('user_id', $user->id)->exists()) { + return 'Shared with you'; + } + + return null; + }) ->url(function (?LibraryItem $record): ?string { if (! $record) { return null; diff --git a/src/Resources/Pages/ListLibraryItems.php b/src/Resources/Pages/ListLibraryItems.php index e444218..3f6fbf5 100644 --- a/src/Resources/Pages/ListLibraryItems.php +++ b/src/Resources/Pages/ListLibraryItems.php @@ -243,6 +243,11 @@ protected function getTableQuery(): Builder // Creators can see their own items (even if private) if ($user) { $q->orWhere('created_by', $user->id); + + // Users can see items explicitly shared with them + $q->orWhereHas('permissions', function ($pq) use ($user) { + $pq->where('user_id', $user->id); + }); } }) ->where('name', 'not like', "%'s Personal Folder");