-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLibrarySeeder.php
More file actions
374 lines (342 loc) · 14.2 KB
/
LibrarySeeder.php
File metadata and controls
374 lines (342 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?php
namespace Tapp\FilamentLibrary\Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Tapp\FilamentLibrary\Models\LibraryItem;
use Tapp\FilamentLibrary\Models\LibraryItemPermission;
class LibrarySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Get the first user as the creator
$user = User::first();
if (! $user) {
$this->command->warn('No users found. Please create a user first.');
return;
}
$this->command->info('Clearing existing library data...');
// Force delete all existing library items and permissions
LibraryItemPermission::query()->forceDelete();
LibraryItem::query()->forceDelete();
$this->command->info('Creating sample library structure...');
// Create root folders with descriptive names
$documents = LibraryItem::create([
'name' => 'Project Documents & Files',
'type' => 'folder',
'created_by' => $user->id,
]);
$images = LibraryItem::create([
'name' => 'Images & Media Assets',
'type' => 'folder',
'created_by' => $user->id,
]);
$resources = LibraryItem::create([
'name' => 'External Links & Resources',
'type' => 'folder',
'created_by' => $user->id,
]);
// Create subfolders under Documents
$projects = LibraryItem::create([
'name' => 'Active Projects',
'type' => 'folder',
'parent_id' => $documents->id,
'created_by' => $user->id,
]);
$templates = LibraryItem::create([
'name' => 'Document Templates',
'type' => 'folder',
'parent_id' => $documents->id,
'created_by' => $user->id,
]);
$meetings = LibraryItem::create([
'name' => 'Meeting Notes & Minutes',
'type' => 'folder',
'parent_id' => $documents->id,
'created_by' => $user->id,
]);
// Create project subfolders
$projectA = LibraryItem::create([
'name' => 'Website Redesign Project',
'type' => 'folder',
'parent_id' => $projects->id,
'created_by' => $user->id,
]);
$projectB = LibraryItem::create([
'name' => 'Mobile App Development',
'type' => 'folder',
'parent_id' => $projects->id,
'created_by' => $user->id,
]);
// Create subfolders under Images
$photos = LibraryItem::create([
'name' => 'Team Photos & Events',
'type' => 'folder',
'parent_id' => $images->id,
'created_by' => $user->id,
]);
$graphics = LibraryItem::create([
'name' => 'Graphics & Design Assets',
'type' => 'folder',
'parent_id' => $images->id,
'created_by' => $user->id,
]);
$logos = LibraryItem::create([
'name' => 'Logos & Branding',
'type' => 'folder',
'parent_id' => $images->id,
'created_by' => $user->id,
]);
// Create subfolders under Resources
$videoResources = LibraryItem::create([
'name' => 'Video Tutorials & Demos',
'type' => 'folder',
'parent_id' => $resources->id,
'created_by' => $user->id,
]);
$documentation = LibraryItem::create([
'name' => 'Documentation & Guides',
'type' => 'folder',
'parent_id' => $resources->id,
'created_by' => $user->id,
]);
$tools = LibraryItem::create([
'name' => 'Development Tools & Links',
'type' => 'folder',
'parent_id' => $resources->id,
'created_by' => $user->id,
]);
// Create some sample files (without actual media attachments for now)
$sampleFiles = [
// Website Redesign Project files
[
'name' => 'Project Overview & Requirements.md',
'parent_id' => $projectA->id,
],
[
'name' => 'Technical Specifications.pdf',
'parent_id' => $projectA->id,
],
[
'name' => 'Design Mockups & Wireframes.zip',
'parent_id' => $projectA->id,
],
[
'name' => 'Development Timeline.xlsx',
'parent_id' => $projectA->id,
],
// Mobile App Development files
[
'name' => 'App Architecture Document.pdf',
'parent_id' => $projectB->id,
],
[
'name' => 'User Stories & Requirements.docx',
'parent_id' => $projectB->id,
],
[
'name' => 'API Documentation.md',
'parent_id' => $projectB->id,
],
// Template files
[
'name' => 'Project Proposal Template.docx',
'parent_id' => $templates->id,
],
[
'name' => 'Meeting Agenda Template.docx',
'parent_id' => $templates->id,
],
[
'name' => 'Technical Review Checklist.pdf',
'parent_id' => $templates->id,
],
// Meeting notes
[
'name' => 'Weekly Team Standup - Jan 15, 2024.txt',
'parent_id' => $meetings->id,
],
[
'name' => 'Project Kickoff Meeting Notes.docx',
'parent_id' => $meetings->id,
],
[
'name' => 'Client Feedback Session - Jan 20, 2024.pdf',
'parent_id' => $meetings->id,
],
];
foreach ($sampleFiles as $fileData) {
LibraryItem::create([
'name' => $fileData['name'],
'type' => 'file',
'parent_id' => $fileData['parent_id'],
'created_by' => $user->id,
]);
}
// Create sample external links - both video and non-video
$sampleLinks = [
// Video Tutorials & Demos
[
'name' => 'Laravel 11 Complete Tutorial - YouTube',
'external_url' => 'https://www.youtube.com/watch?v=ImtZ5yENzgE',
'link_icon' => 'heroicon-o-play',
'link_description' => 'Complete Laravel 11 tutorial covering all features',
'parent_id' => $videoResources->id,
],
[
'name' => 'Filament Admin Panel Demo - Vimeo',
'external_url' => 'https://vimeo.com/123456789',
'link_icon' => 'heroicon-o-video-camera',
'link_description' => 'Comprehensive Filament admin panel demonstration',
'parent_id' => $videoResources->id,
],
[
'name' => 'Wistia Video Testing Example',
'external_url' => 'https://tappnetwork.wistia.com/medias/abc123def',
'link_icon' => 'heroicon-o-film',
'link_description' => 'Example Wistia video for testing video embedding',
'parent_id' => $videoResources->id,
],
[
'name' => 'React vs Vue.js Comparison - YouTube',
'external_url' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
'link_icon' => 'heroicon-o-play',
'link_description' => 'Detailed comparison between React and Vue.js frameworks',
'parent_id' => $videoResources->id,
],
// Documentation & Guides
[
'name' => 'Laravel Official Documentation',
'external_url' => 'https://laravel.com/docs',
'link_icon' => 'heroicon-o-book-open',
'link_description' => 'Official Laravel framework documentation',
'parent_id' => $documentation->id,
],
[
'name' => 'Filament Documentation',
'external_url' => 'https://filamentphp.com/docs',
'link_icon' => 'heroicon-o-academic-cap',
'link_description' => 'Complete Filament admin panel documentation',
'parent_id' => $documentation->id,
],
[
'name' => 'PHP Best Practices Guide',
'external_url' => 'https://www.php.net/manual/en/',
'link_icon' => 'heroicon-o-document-text',
'link_description' => 'PHP official manual and best practices',
'parent_id' => $documentation->id,
],
[
'name' => 'MySQL Database Design Guide',
'external_url' => 'https://dev.mysql.com/doc/',
'link_icon' => 'heroicon-o-circle-stack',
'link_description' => 'MySQL database design and optimization guide',
'parent_id' => $documentation->id,
],
// Development Tools & Links
[
'name' => 'GitHub Repository - Filament Library',
'external_url' => 'https://github.com/TappNetwork/Filament-Library',
'link_icon' => 'heroicon-o-code-bracket',
'link_description' => 'Source code for this Filament Library plugin',
'parent_id' => $tools->id,
],
[
'name' => 'Stack Overflow - Laravel Questions',
'external_url' => 'https://stackoverflow.com/questions/tagged/laravel',
'link_icon' => 'heroicon-o-question-mark-circle',
'link_description' => 'Laravel questions and answers community',
'parent_id' => $tools->id,
],
[
'name' => 'Composer Package Manager',
'external_url' => 'https://packagist.org/',
'link_icon' => 'heroicon-o-puzzle-piece',
'link_description' => 'PHP package repository and manager',
'parent_id' => $tools->id,
],
[
'name' => 'Laravel Forge - Server Management',
'external_url' => 'https://forge.laravel.com/',
'link_icon' => 'heroicon-o-server',
'link_description' => 'Laravel Forge for server deployment and management',
'parent_id' => $tools->id,
],
// Project-specific links
[
'name' => 'Website Design Inspiration - Dribbble',
'external_url' => 'https://dribbble.com/shots/example',
'link_icon' => 'heroicon-o-paint-brush',
'link_description' => 'Design inspiration for website redesign project',
'parent_id' => $projectA->id,
],
[
'name' => 'Mobile App UI Kit - Figma',
'external_url' => 'https://figma.com/example-ui-kit',
'link_icon' => 'heroicon-o-device-phone-mobile',
'link_description' => 'UI kit for mobile app development project',
'parent_id' => $projectB->id,
],
[
'name' => 'Brand Guidelines - Company Wiki',
'external_url' => 'https://company-wiki.com/brand-guidelines',
'link_icon' => 'heroicon-o-identification',
'link_description' => 'Company brand guidelines and logo usage',
'parent_id' => $logos->id,
],
];
foreach ($sampleLinks as $linkData) {
LibraryItem::create([
'name' => $linkData['name'],
'type' => 'link',
'external_url' => $linkData['external_url'],
'link_icon' => $linkData['link_icon'],
'link_description' => $linkData['link_description'],
'parent_id' => $linkData['parent_id'],
'created_by' => $user->id,
]);
}
// Create some sample permissions if there are other users
$otherUsers = User::where('id', '!=', $user->id)->take(2)->get();
if ($otherUsers->count() > 0) {
$this->command->info('Creating sample permissions...');
// Give first other user view access to Documents folder
if ($otherUsers->count() >= 1) {
LibraryItemPermission::create([
'library_item_id' => $documents->id,
'user_id' => $otherUsers[0]->id,
'permission' => 'view',
]);
}
// Give second other user edit access to Project A
if ($otherUsers->count() >= 2) {
LibraryItemPermission::create([
'library_item_id' => $projectA->id,
'user_id' => $otherUsers[1]->id,
'permission' => 'edit',
]);
}
}
$this->command->info('Sample library structure created successfully!');
$this->command->info('Created:');
$this->command->info('Project Documents & Files/');
$this->command->info(' Active Projects/');
$this->command->info(' Website Redesign Project/ (with 4 files + 1 link)');
$this->command->info(' Mobile App Development/ (with 3 files + 1 link)');
$this->command->info(' Document Templates/ (with 3 template files)');
$this->command->info(' Meeting Notes & Minutes/ (with 3 meeting files)');
$this->command->info('Images & Media Assets/');
$this->command->info(' Team Photos & Events/');
$this->command->info(' Graphics & Design Assets/');
$this->command->info(' Logos & Branding/ (with 1 brand guidelines link)');
$this->command->info('External Links & Resources/');
$this->command->info(' Video Tutorials & Demos/ (with 4 video links)');
$this->command->info(' Documentation & Guides/ (with 4 documentation links)');
$this->command->info(' Development Tools & Links/ (with 4 tool links)');
if ($otherUsers->count() > 0) {
$this->command->info('Sample permissions created for other users.');
}
}
}