Skip to content

Commit 3e8b1b1

Browse files
scott graysonscott grayson
authored andcommitted
feat: implement plugin foundation with basic models and database schema
- Create LibraryItem model with Spatie Media Library integration - Create LibraryItemPermission model for user permissions - Add HasLibraryAccess trait for user model integration - Implement PermissionService with Google Drive-style inheritance - Add database migrations for library_items and permissions tables - Create configuration file with sensible defaults - Add test seeder for sample data - Update service provider and plugin structure - Fix MySQL constraint name length issues
1 parent fb731cd commit 3e8b1b1

20 files changed

+1024
-141
lines changed

composer.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
{
2-
"name": ":vendor_slug/:package_slug",
3-
"description": ":package_description",
2+
"name": "tapp/filament-library",
3+
"description": "A Google Drive-like file management system for Filament",
44
"keywords": [
5-
":vendor_name",
5+
"tapp",
66
"laravel",
7-
":package_slug"
7+
"filament",
8+
"library",
9+
"file-management"
810
],
9-
"homepage": "https://github.com/:vendor_slug/:package_slug",
11+
"homepage": "https://github.com/TappNetwork/Filament-Library",
1012
"support": {
11-
"issues": "https://github.com/:vendor_slug/:package_slug/issues",
12-
"source": "https://github.com/:vendor_slug/:package_slug"
13+
"issues": "https://github.com/TappNetwork/Filament-Library/issues",
14+
"source": "https://github.com/TappNetwork/Filament-Library"
1315
},
1416
"license": "MIT",
1517
"authors": [
1618
{
17-
"name": ":author_name",
18-
"email": "author@domain.com",
19+
"name": "Tapp Network",
20+
"email": "dev@tappnetwork.com",
1921
"role": "Developer"
2022
}
2123
],
2224
"require": {
2325
"php": "^8.1",
24-
"filament/filament": "^3.0",
25-
"filament/forms": "^3.0",
26-
"filament/tables": "^3.0",
27-
"spatie/laravel-package-tools": "^1.15.0"
26+
"filament/filament": "^4.0",
27+
"illuminate/contracts": "^10.0|^11.0",
28+
"spatie/laravel-package-tools": "^1.15.0",
29+
"spatie/laravel-medialibrary": "^11.0",
30+
"filament/spatie-laravel-media-library-plugin": "^4.0"
2831
},
2932
"require-dev": {
3033
"laravel/pint": "^1.0",
@@ -41,13 +44,13 @@
4144
},
4245
"autoload": {
4346
"psr-4": {
44-
"VendorName\\Skeleton\\": "src/",
45-
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
47+
"Tapp\\FilamentLibrary\\": "src/",
48+
"Tapp\\FilamentLibrary\\Database\\Factories\\": "database/factories/"
4649
}
4750
},
4851
"autoload-dev": {
4952
"psr-4": {
50-
"VendorName\\Skeleton\\Tests\\": "tests/"
53+
"Tapp\\FilamentLibrary\\Tests\\": "tests/"
5154
}
5255
},
5356
"scripts": {
@@ -67,10 +70,10 @@
6770
"extra": {
6871
"laravel": {
6972
"providers": [
70-
"VendorName\\Skeleton\\SkeletonServiceProvider"
73+
"Tapp\\FilamentLibrary\\FilamentLibraryServiceProvider"
7174
],
7275
"aliases": {
73-
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
76+
"FilamentLibrary": "Tapp\\FilamentLibrary\\Facades\\FilamentLibrary"
7477
}
7578
}
7679
},

config/filament-library.php

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Library Configuration
7+
|--------------------------------------------------------------------------
8+
|
9+
| Configuration options for the Filament Library plugin.
10+
|
11+
*/
12+
13+
/*
14+
|--------------------------------------------------------------------------
15+
| Maximum Nesting Depth
16+
|--------------------------------------------------------------------------
17+
|
18+
| The maximum number of levels deep that folders can be nested.
19+
| Set to null for unlimited nesting.
20+
|
21+
*/
22+
'max_nesting_depth' => 5,
23+
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Soft Delete Days
27+
|--------------------------------------------------------------------------
28+
|
29+
| Number of days to keep soft-deleted items before permanent deletion.
30+
| Set to null to disable automatic cleanup.
31+
|
32+
*/
33+
'soft_delete_days' => 30,
34+
35+
/*
36+
|--------------------------------------------------------------------------
37+
| Table Columns
38+
|--------------------------------------------------------------------------
39+
|
40+
| Configuration for which columns to show in the library table.
41+
|
42+
*/
43+
'table_columns' => [
44+
'name' => true,
45+
'type' => true,
46+
'size' => true,
47+
'created_at' => true,
48+
'updated_at' => false,
49+
],
50+
51+
/*
52+
|--------------------------------------------------------------------------
53+
| File Operations
54+
|--------------------------------------------------------------------------
55+
|
56+
| Configuration for file upload and handling.
57+
|
58+
*/
59+
'file_operations' => [
60+
'allowed_mime_types' => [
61+
'image/*',
62+
'application/pdf',
63+
'text/*',
64+
'application/msword',
65+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
66+
'application/vnd.ms-excel',
67+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
68+
'application/vnd.ms-powerpoint',
69+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
70+
'application/zip',
71+
'application/x-rar-compressed',
72+
],
73+
'max_file_size' => 50 * 1024 * 1024, // 50MB default
74+
],
75+
76+
/*
77+
|--------------------------------------------------------------------------
78+
| Media Library Configuration
79+
|--------------------------------------------------------------------------
80+
|
81+
| Configuration for Spatie Media Library integration.
82+
| Most settings are handled by the Media Library's own configuration.
83+
|
84+
*/
85+
'media_library' => [
86+
'collection_name' => 'files',
87+
'conversion_name' => 'thumb',
88+
'disk' => null, // Use Media Library's default disk
89+
],
90+
91+
/*
92+
|--------------------------------------------------------------------------
93+
| Permission Configuration
94+
|--------------------------------------------------------------------------
95+
|
96+
| Configuration for permission handling and caching.
97+
|
98+
*/
99+
'permissions' => [
100+
'cache_ttl' => 3600, // 1 hour
101+
'auto_inherit' => true, // Automatically inherit parent permissions
102+
'cascade_on_change' => true, // Cascade permission changes to children
103+
],
104+
105+
/*
106+
|--------------------------------------------------------------------------
107+
| User Model Configuration
108+
|--------------------------------------------------------------------------
109+
|
110+
| Configuration for user model integration.
111+
|
112+
*/
113+
'user_model' => \App\Models\User::class,
114+
115+
/*
116+
|--------------------------------------------------------------------------
117+
| Navigation Configuration
118+
|--------------------------------------------------------------------------
119+
|
120+
| Configuration for Filament navigation integration.
121+
|
122+
*/
123+
'navigation' => [
124+
'group' => 'Library',
125+
'icon' => 'heroicon-o-folder',
126+
'sort' => 10,
127+
],
128+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('library_items', function (Blueprint $table) {
15+
$table->id();
16+
$table->string('name');
17+
$table->string('slug');
18+
$table->enum('type', ['folder', 'file']);
19+
$table->foreignId('parent_id')->nullable()->constrained('library_items')->cascadeOnDelete();
20+
$table->foreignId('created_by')->constrained('users');
21+
$table->timestamps();
22+
$table->softDeletes();
23+
24+
$table->index(['parent_id', 'type']);
25+
$table->unique(['parent_id', 'slug'], 'lib_items_parent_slug_unique');
26+
});
27+
}
28+
29+
/**
30+
* Reverse the migrations.
31+
*/
32+
public function down(): void
33+
{
34+
Schema::dropIfExists('library_items');
35+
}
36+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('library_item_permissions', function (Blueprint $table) {
15+
$table->id();
16+
$table->foreignId('library_item_id')->constrained()->cascadeOnDelete();
17+
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
18+
$table->enum('permission', ['view', 'edit']);
19+
$table->timestamps();
20+
21+
$table->unique(['library_item_id', 'user_id', 'permission'], 'lib_item_perms_unique');
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*/
28+
public function down(): void
29+
{
30+
Schema::dropIfExists('library_item_permissions');
31+
}
32+
};

database/migrations/create_skeleton_table.php.stub

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)