Skip to content

Commit 23596f7

Browse files
authored
Merge pull request #6 from TappNetwork/tenancy
Multi-tenancy support
2 parents f0dd7a9 + ba8771f commit 23596f7

20 files changed

+639
-131
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: :vendor_name
1+
github: TappNetwork

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Security Policy
22

3-
If you discover any security related issues, please email author@domain.com instead of using the issue tracker.
3+
If you discover any security related issues, please email steve@tappnetwork.com instead of using the issue tracker.

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Details
2+
3+
Details of the feature / fix this PR addresses.

README.md

Lines changed: 89 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ A comprehensive file and document management system for Filament applications, f
55
## Features
66

77
- **📁 File & Folder Management** - Upload files, create folders, and organize content
8-
- **🔗 External Links** - Add and manage external links with descriptions
8+
- **🔗 External Links** - Add and manage external links with descriptions (including video embeds)
99
- **👥 Advanced Permissions** - Google Drive-style ownership with Creator, Owner, Editor, and Viewer roles
1010
- **🔄 Automatic Inheritance** - Permissions automatically inherit from parent folders
11-
- **🔍 Multiple Views** - Public Library, My Documents, Shared with Me, Created by Me, and Search All
11+
- **🔍 Multiple Views** - Public Library, My Documents, Shared with Me, Created by Me, Favorites, and Search All
12+
- **🏷️ Tags & Favorites** - Organize items with tags and mark favorites for quick access
1213
- **⚙️ Configurable Admin Access** - Flexible admin role configuration
1314
- **🎨 Filament Integration** - Native Filament UI components and navigation
15+
- **🏢 Multi-Tenancy Support** - Optional team/organization scoping for all library content
1416

1517
## Installation
1618

@@ -35,6 +37,9 @@ class User extends Authenticatable
3537
}
3638
```
3739

40+
> [!WARNING]
41+
> If you are using multi-tenancy please see the "Multi-Tenancy Support" instructions below **before** publishing and running migrations.
42+
3843
You can publish and run the migrations with:
3944

4045
```bash
@@ -86,16 +91,17 @@ public function boot()
8691

8792
### 3. Navigation
8893

89-
The plugin automatically adds navigation items:
94+
The plugin automatically adds navigation items under "Resource Library":
9095
- **Library** - Main library view
9196
- **Search All** - Search across all accessible content
9297
- **My Documents** - Personal documents and folders
9398
- **Shared with Me** - Items shared by other users
9499
- **Created by Me** - Items you created
100+
- **Favorites** - Items you've marked as favorites
95101

96102
## Permissions System
97103

98-
The plugin features a sophisticated permissions system inspired by Google Drive. See [Permissions Documentation](docs/permissions.md) for complete details.
104+
The plugin features a sophisticated permissions system inspired by Google Drive.
99105

100106
### Quick Overview
101107

@@ -110,29 +116,95 @@ The plugin features a sophisticated permissions system inspired by Google Drive.
110116
- **Permission Inheritance** - Child items inherit parent folder permissions
111117
- **Admin Override** - Library admins can access all content
112118

119+
## Multi-Tenancy Support
120+
121+
Filament Library includes built-in support for multi-tenancy, allowing you to scope library items, permissions, and tags to specific tenants (e.g., teams, organizations, workspaces).
122+
123+
### ⚠️ Important: Enable Tenancy Before Migrations
124+
125+
**You MUST configure and enable tenancy in the config file BEFORE running the migrations.** The migrations check the tenancy configuration to determine whether to add tenant columns to the database tables. If you enable tenancy after running migrations, you'll need to manually add the tenant columns to your database.
126+
127+
### Quick Setup
128+
129+
1. **Configure your Filament panel with tenancy** (see [Filament Tenancy docs](https://filamentphp.com/docs/4.x/users/tenancy))
130+
2. **Publish the config file**:
131+
```bash
132+
php artisan vendor:publish --tag="filament-library-config"
133+
```
134+
3. **Enable tenancy in `config/filament-library.php`**:
135+
```php
136+
'tenancy' => [
137+
'enabled' => true, // ⚠️ Set this BEFORE running migrations!
138+
'model' => \App\Models\Team::class,
139+
],
140+
```
141+
4. **Run migrations**:
142+
```bash
143+
php artisan migrate
144+
```
145+
146+
For complete setup instructions, troubleshooting, and advanced configuration, see [TENANCY.md](TENANCY.md).
147+
113148
## Configuration
114149

115-
### Admin Role Configuration
150+
The config file (`config/filament-library.php`) includes the following options:
151+
152+
### User Model
116153

117154
```php
118-
// config/filament-library.php
119-
return [
120-
'admin_role' => 'Admin', // Default admin role
121-
'admin_callback' => null, // Custom callback function
122-
];
155+
'user_model' => env('FILAMENT_LIBRARY_USER_MODEL', 'App\\Models\\User'),
123156
```
124157

125-
### Environment Variables
158+
Specify the user model for the application.
126159

127-
```env
128-
LIBRARY_ADMIN_ROLE=super-admin
160+
### Video Link Support (Optional)
161+
162+
The library supports video links from various platforms. To customize supported domains, add this to your config:
163+
164+
```php
165+
'video' => [
166+
'supported_domains' => [
167+
'youtube.com',
168+
'youtu.be',
169+
'vimeo.com',
170+
'wistia.com',
171+
],
172+
],
173+
```
174+
175+
### Secure File URLs (Optional)
176+
177+
Configure how long temporary download URLs remain valid:
178+
179+
```php
180+
'url' => [
181+
'temporary_expiration_minutes' => 60, // Default: 60 minutes
182+
],
129183
```
130184

131-
## Documentation
185+
### Admin Access Configuration (Optional)
186+
187+
To configure which users can access admin features, add this to your config:
188+
189+
```php
190+
'admin_role' => 'Admin', // Role name to check
191+
'admin_callback' => null, // Custom callback function
192+
```
193+
194+
Or set it programmatically in your `AppServiceProvider`:
195+
196+
```php
197+
use Tapp\FilamentLibrary\FilamentLibraryPlugin;
198+
199+
public function boot()
200+
{
201+
FilamentLibraryPlugin::setLibraryAdminCallback(function ($user) {
202+
return $user->hasRole('super-admin');
203+
});
204+
}
205+
```
132206

133-
- [Permissions System](docs/permissions.md) - Complete permissions guide
134-
- [Customization Guide](docs/customization.md) - Customizing admin access
135-
- [API Reference](docs/api.md) - Developer documentation
207+
**Note:** By default, users have an `isLibraryAdmin()` method that returns `false`. You can override this in your User model for custom logic.
136208

137209
## Testing
138210

0 commit comments

Comments
 (0)