Skip to content

Commit 57acdf2

Browse files
authored
Merge pull request #9 from TappNetwork/bugfixes
Add tags field to edit resource forms (EditFile, EditLink, EditFolder)
2 parents c18a95e + 2832512 commit 57acdf2

File tree

7 files changed

+67
-5
lines changed

7 files changed

+67
-5
lines changed

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.1'
19+
php-version: '8.3'
2020
coverage: none
2121

2222
- name: Install composer dependencies

src/Resources/LibraryItemResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public static function form(Schema $schema): Schema
9595
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('files')
9696
->label('File')
9797
->visible(fn (callable $get) => $get('type') === 'file')
98-
->required(fn (callable $get) => $get('type') === 'file'),
98+
->required(fn (callable $get) => $get('type') === 'file')
99+
->maxSize(512000), // 500MB
99100

100101
// Link form fields
101102
\Filament\Forms\Components\TextInput::make('external_url')

src/Resources/Pages/EditFile.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,33 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
3737
->maxLength(255),
3838

3939
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('files')
40-
->label('File'),
40+
->label('File')
41+
->maxSize(512000), // 500MB
4142

4243
\Filament\Forms\Components\Textarea::make('link_description')
4344
->label('Description')
4445
->rows(3),
4546

47+
\Filament\Forms\Components\Select::make('tags')
48+
->label('Tags')
49+
->relationship('tags', 'name')
50+
->multiple()
51+
->searchable()
52+
->preload()
53+
->createOptionForm([
54+
\Filament\Forms\Components\TextInput::make('name')
55+
->required()
56+
->maxLength(255),
57+
])
58+
->createOptionUsing(function (array $data): int {
59+
$tag = \Tapp\FilamentLibrary\Models\LibraryItemTag::create([
60+
'name' => $data['name'],
61+
'slug' => \Illuminate\Support\Str::slug($data['name']),
62+
]);
63+
64+
return $tag->id;
65+
}),
66+
4667
\Filament\Forms\Components\Select::make('general_access')
4768
->label('General Access')
4869
->options(function () {

src/Resources/Pages/EditFolder.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
2828
->label('Description')
2929
->rows(3),
3030

31+
\Filament\Forms\Components\Select::make('tags')
32+
->label('Tags')
33+
->relationship('tags', 'name')
34+
->multiple()
35+
->searchable()
36+
->preload()
37+
->createOptionForm([
38+
\Filament\Forms\Components\TextInput::make('name')
39+
->required()
40+
->maxLength(255),
41+
])
42+
->createOptionUsing(function (array $data): int {
43+
$tag = \Tapp\FilamentLibrary\Models\LibraryItemTag::create([
44+
'name' => $data['name'],
45+
'slug' => \Illuminate\Support\Str::slug($data['name']),
46+
]);
47+
48+
return $tag->id;
49+
}),
50+
3151
Select::make('general_access')
3252
->label('General Access')
3353
->options(function () {

src/Resources/Pages/EditLink.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
3232
->label('Description')
3333
->rows(3),
3434

35+
\Filament\Forms\Components\Select::make('tags')
36+
->label('Tags')
37+
->relationship('tags', 'name')
38+
->multiple()
39+
->searchable()
40+
->preload()
41+
->createOptionForm([
42+
\Filament\Forms\Components\TextInput::make('name')
43+
->required()
44+
->maxLength(255),
45+
])
46+
->createOptionUsing(function (array $data): int {
47+
$tag = \Tapp\FilamentLibrary\Models\LibraryItemTag::create([
48+
'name' => $data['name'],
49+
'slug' => \Illuminate\Support\Str::slug($data['name']),
50+
]);
51+
52+
return $tag->id;
53+
}),
54+
3555
\Filament\Forms\Components\Select::make('general_access')
3656
->label('General Access')
3757
->options(function () {

src/Resources/Pages/ListLibraryItems.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function getHeaderActions(): array
123123
FileUpload::make('file')
124124
->label('Upload File')
125125
->required()
126-
->maxSize(10240) // 10MB
126+
->maxSize(512000) // 500MB
127127
->disk('public')
128128
->directory('library-files')
129129
->visibility('private')

src/Resources/Pages/MyLibrary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function getHeaderActions(): array
8989
\Filament\Forms\Components\FileUpload::make('file')
9090
->label('Upload File')
9191
->required()
92-
->maxSize(10240) // 10MB
92+
->maxSize(512000) // 500MB
9393
->disk('public')
9494
->directory('library-files')
9595
->visibility('private')

0 commit comments

Comments
 (0)