mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 00:02:15 +00:00
deleted pro code
This commit is contained in:
@@ -11,8 +11,6 @@ use Illuminate\Support\Facades\DB;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Domain\Teams\Models\TeamFolderInvitation;
|
||||
use Domain\Pages\Actions\SeedDefaultPagesAction;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Domain\Settings\Actions\SeedDefaultSettingsAction;
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageAction;
|
||||
@@ -25,7 +23,7 @@ class SetupDevEnvironment extends Command
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
protected $signature = 'setup:dev {license=extended}';
|
||||
protected $signature = 'setup:dev';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -36,7 +34,6 @@ class SetupDevEnvironment extends Command
|
||||
private CreateDiskDirectoriesAction $createDiskDirectories,
|
||||
private SeedDefaultSettingsAction $seedDefaultSettings,
|
||||
private SeedDefaultLanguageAction $seedDefaultLanguage,
|
||||
private SeedDefaultPagesAction $seedDefaultPages,
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->setUpFaker();
|
||||
@@ -56,8 +53,7 @@ class SetupDevEnvironment extends Command
|
||||
$this->migrate_and_generate();
|
||||
|
||||
$this->info('Storing default settings and content...');
|
||||
($this->seedDefaultPages)();
|
||||
($this->seedDefaultSettings)($this->argument('license'));
|
||||
($this->seedDefaultSettings)();
|
||||
($this->seedDefaultLanguage)();
|
||||
$this->store_default_settings();
|
||||
|
||||
@@ -69,15 +65,9 @@ class SetupDevEnvironment extends Command
|
||||
|
||||
$this->info('Creating default demo content...');
|
||||
$this->create_admin_default_content();
|
||||
$this->create_team_folders_content();
|
||||
$this->create_share_with_me_team_folders_content();
|
||||
$this->create_share_records();
|
||||
$this->generate_traffic();
|
||||
|
||||
$this->generateCommonNotification();
|
||||
$this->generateTeamInvitationNotification();
|
||||
$this->generateFileRequestFilledNotification();
|
||||
|
||||
$this->info('Clearing application cache...');
|
||||
$this->clear_cache();
|
||||
|
||||
@@ -91,135 +81,6 @@ class SetupDevEnvironment extends Command
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
private function generateCommonNotification()
|
||||
{
|
||||
$howdy = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
DB::table('notifications')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'type' => 'App\Users\Notifications\RegistrationBonusAddedNotification',
|
||||
'notifiable_type' => 'App\Users\Models\User',
|
||||
'notifiable_id' => $howdy->id,
|
||||
'data' => json_encode([
|
||||
'category' => 'gift',
|
||||
'title' => 'You Received $10.00',
|
||||
'description' => 'You received credit bonus $10.00 for your registration. Happy spending!',
|
||||
]),
|
||||
'read_at' => now()->subMinutes(5),
|
||||
'created_at' => now()->subMinutes(5),
|
||||
'updated_at' => now()->subMinutes(5),
|
||||
]);
|
||||
}
|
||||
|
||||
private function generateTeamInvitationNotification()
|
||||
{
|
||||
$alice = User::whereEmail('alice@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$howdy = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$newV2Wallpaper = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $alice->id,
|
||||
'team_folder' => true,
|
||||
'name' => 'New v2 Wallpaper',
|
||||
]);
|
||||
|
||||
$invitation = TeamFolderInvitation::factory()
|
||||
->create([
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'parent_id' => $newV2Wallpaper->id,
|
||||
'inviter_id' => $newV2Wallpaper->user_id,
|
||||
'status' => 'pending',
|
||||
'permission' => 'can-edit',
|
||||
]);
|
||||
|
||||
DB::table('notifications')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
|
||||
'notifiable_type' => 'App\Users\Models\User',
|
||||
'notifiable_id' => $howdy->id,
|
||||
'data' => json_encode([
|
||||
'category' => 'team-invitation',
|
||||
'title' => 'New Team Invitation',
|
||||
'description' => 'Jane Doe invite you to join into Team Folder.',
|
||||
'action' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'id' => $invitation->id,
|
||||
],
|
||||
],
|
||||
]),
|
||||
'read_at' => now(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function generateFileRequestFilledNotification()
|
||||
{
|
||||
$howdy = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$sharedFolder = Folder::where('name', 'Shared Folder')
|
||||
->first();
|
||||
|
||||
$fileRequestFolder = Folder::factory()
|
||||
->create([
|
||||
'parent_id' => $sharedFolder->id,
|
||||
'user_id' => $howdy->id,
|
||||
'team_folder' => false,
|
||||
'name' => 'Upload Request from 10. Mar. 2022',
|
||||
]);
|
||||
|
||||
DB::table('notifications')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
|
||||
'notifiable_type' => 'App\Users\Models\User',
|
||||
'notifiable_id' => $howdy->id,
|
||||
'data' => json_encode([
|
||||
'category' => 'file-request',
|
||||
'title' => 'File Request Filled',
|
||||
'description' => "Your file request for 'Shared Folder' folder was filled successfully.",
|
||||
'action' => [
|
||||
'type' => 'route',
|
||||
'params' => [
|
||||
'route' => 'Files',
|
||||
'button' => 'Show Files',
|
||||
'id' => $fileRequestFolder->id,
|
||||
],
|
||||
],
|
||||
]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'demo/request/v2-wallpaper.jpg',
|
||||
])
|
||||
->each(function ($file) use ($howdy, $fileRequestFolder) {
|
||||
$thumbnail = $this->generate_thumbnails($file, $howdy);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $fileRequestFolder->id,
|
||||
'user_id' => $howdy->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default admin account
|
||||
*/
|
||||
@@ -830,527 +691,6 @@ class SetupDevEnvironment extends Command
|
||||
});
|
||||
}
|
||||
|
||||
private function create_team_folders_content(): void
|
||||
{
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$alice = User::whereEmail('alice@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$johan = User::whereEmail('johan@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$users = [$user, $alice, $johan];
|
||||
|
||||
// 1. Company project
|
||||
$companyProjectFolder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => true,
|
||||
'name' => 'Company Project',
|
||||
]);
|
||||
|
||||
$presentationMaterial = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $companyProjectFolder->id,
|
||||
'name' => 'Presentation Materials',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
$teamGallery = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $companyProjectFolder->id,
|
||||
'name' => 'Team Gallery',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
collect([
|
||||
'demo/images/team-gallery/photo-1.jpeg',
|
||||
'demo/images/team-gallery/photo-2.jpeg',
|
||||
'demo/images/team-gallery/photo-3.jpeg',
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $teamGallery) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$thumbnail = $this->generate_thumbnails($file, $user);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $teamGallery->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
collect([
|
||||
'demo/images/presentation/photo-1.jpeg',
|
||||
'demo/images/presentation/photo-2.jpeg',
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $presentationMaterial) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$thumbnail = $this->generate_thumbnails($file, $user);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $presentationMaterial->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// 2. Finance Documents
|
||||
$financeDocumentsFolder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => true,
|
||||
'name' => 'Finance Documents',
|
||||
]);
|
||||
|
||||
$reserves = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $financeDocumentsFolder->id,
|
||||
'name' => 'Reserves',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
$otherDocuments = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $financeDocumentsFolder->id,
|
||||
'name' => 'Other Documents',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
collect([
|
||||
'demo/images/finance-documents/photo-1.jpeg',
|
||||
'demo/images/finance-documents/photo-2.jpeg',
|
||||
'demo/images/finance-documents/photo-3.jpeg',
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $financeDocumentsFolder) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$thumbnail = $this->generate_thumbnails($file, $user);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $financeDocumentsFolder->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
collect([
|
||||
'demo/images/finance-documents/photo-4.jpeg',
|
||||
'demo/images/finance-documents/photo-5.jpeg',
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $reserves) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$thumbnail = $this->generate_thumbnails($file, $user);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $reserves->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get documents to root directory
|
||||
collect([
|
||||
[
|
||||
'name' => 'Next Year Projection',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Budget.pdf',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => '2022 Yearly Report.pages',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'Company Project Notes.pages',
|
||||
'basename' => 'Stories of the Night Skies.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'Finance Stories.pages',
|
||||
'basename' => 'Stories of the Night Skies.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $financeDocumentsFolder, $otherDocuments) {
|
||||
$author = $users[rand(0, 2)];
|
||||
$folder = [$financeDocumentsFolder, $otherDocuments][rand(0, 1)];
|
||||
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// 3. Holiday 2022
|
||||
$holiday2022Folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => true,
|
||||
'name' => 'Holiday 2022',
|
||||
]);
|
||||
|
||||
$destinationGallery = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $holiday2022Folder->id,
|
||||
'name' => 'Destination Gallery',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
collect([
|
||||
'demo/images/destination-gallery/photo-1.jpeg',
|
||||
'demo/images/destination-gallery/photo-2.jpeg',
|
||||
'demo/images/destination-gallery/photo-3.jpeg',
|
||||
'demo/images/destination-gallery/photo-4.jpeg',
|
||||
'demo/images/destination-gallery/photo-5.jpeg',
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $destinationGallery) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$thumbnail = $this->generate_thumbnails($file, $user);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $destinationGallery->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get documents to root directory
|
||||
collect([
|
||||
[
|
||||
'name' => 'Finance.pages',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Fly tickets.pdf',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Documentation.pdf',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($users, $user, $holiday2022Folder) {
|
||||
$author = $users[rand(0, 2)];
|
||||
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $holiday2022Folder->id,
|
||||
'user_id' => $user->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
collect([$companyProjectFolder, $financeDocumentsFolder, $holiday2022Folder])
|
||||
->each(function ($folder) use ($user) {
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'permission' => 'owner',
|
||||
]);
|
||||
});
|
||||
|
||||
// Attach members
|
||||
$members = User::whereNotIn('email', ['howdy@hi5ve.digital'])
|
||||
->get();
|
||||
|
||||
collect([$members[0]->id, $members[1]->id, $members[5]->id])
|
||||
->each(
|
||||
fn ($id) => DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $companyProjectFolder->id,
|
||||
'user_id' => $id,
|
||||
'permission' => 'can-edit',
|
||||
])
|
||||
);
|
||||
|
||||
collect([$members[3]->id, $members[2]->id])
|
||||
->each(
|
||||
fn ($id) => DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $financeDocumentsFolder->id,
|
||||
'user_id' => $id,
|
||||
'permission' => 'can-edit',
|
||||
])
|
||||
);
|
||||
|
||||
collect([$members[2]->id, $members[3]->id, $members[5]->id, $members[0]->id])
|
||||
->each(
|
||||
fn ($id) => DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $holiday2022Folder->id,
|
||||
'user_id' => $id,
|
||||
'permission' => 'can-edit',
|
||||
])
|
||||
);
|
||||
|
||||
// Create invitations
|
||||
collect([$members[4], $members[5]])
|
||||
->each(
|
||||
fn ($user) => TeamFolderInvitation::factory()
|
||||
->create([
|
||||
'email' => $user->email,
|
||||
'parent_id' => $companyProjectFolder->id,
|
||||
'inviter_id' => $companyProjectFolder->user_id,
|
||||
'status' => 'pending',
|
||||
'permission' => 'can-edit',
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function create_share_with_me_team_folders_content(): void
|
||||
{
|
||||
$member = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$owner = User::whereEmail('alice@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$johan = User::whereEmail('johan@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$users = [$member, $johan];
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'team_folder' => true,
|
||||
'name' => "Alice's Project Files",
|
||||
]);
|
||||
|
||||
$videos = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $folder->id,
|
||||
'name' => 'Videos',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
$hug = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $folder->id,
|
||||
'name' => 'Digital Hug',
|
||||
'team_folder' => true,
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'permission' => 'owner',
|
||||
],
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $johan->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
]);
|
||||
|
||||
// Get videos
|
||||
collect([
|
||||
'Apple Watch App Video Promotion.mp4',
|
||||
'Smart Watch 3D Device Pack for Element 3D.mp4',
|
||||
])
|
||||
->each(function ($file) use ($users, $owner, $videos) {
|
||||
$author = $users[rand(0, 1)];
|
||||
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$owner->id", storage_path("demo/video/$file"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $videos->id,
|
||||
'user_id' => $owner->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'video',
|
||||
'mimetype' => 'mp4',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
collect([
|
||||
[
|
||||
'name' => 'Notes',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($users, $owner, $folder) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
$author = $users[rand(0, 1)];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$owner->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'creator_id' => $author->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'demo/images/memes/Sofishticated.jpg',
|
||||
'demo/images/memes/whaaaaat.jpg',
|
||||
])
|
||||
->each(function ($file) use ($owner, $folder) {
|
||||
$thumbnail = $this->generate_thumbnails($file, $owner);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'demo/images/memes/You Are My Sunshine.jpg',
|
||||
])
|
||||
->each(function ($file) use ($johan, $owner, $folder) {
|
||||
$thumbnail = $this->generate_thumbnails($file, $owner);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'creator_id' => $johan->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
collect([
|
||||
'demo/images/memes/Eggcited bro.jpg',
|
||||
'demo/images/memes/Get a Rest.jpg',
|
||||
])
|
||||
->each(function ($file) use ($member, $owner, $hug) {
|
||||
$thumbnail = $this->generate_thumbnails($file, $owner);
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $hug->id,
|
||||
'user_id' => $owner->id,
|
||||
'creator_id' => $member->id,
|
||||
'name' => $thumbnail['name'],
|
||||
'basename' => $thumbnail['basename'],
|
||||
'type' => 'image',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
private function create_share_records(): void
|
||||
{
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
@@ -1450,14 +790,6 @@ class SetupDevEnvironment extends Command
|
||||
'name' => 'registration',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'user_verification',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_payments',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => 1,
|
||||
@@ -1466,17 +798,13 @@ class SetupDevEnvironment extends Command
|
||||
'name' => 'default_max_storage_amount',
|
||||
'value' => 5,
|
||||
],
|
||||
[
|
||||
'name' => 'default_max_team_member',
|
||||
'value' => 10,
|
||||
],
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $this->argument('license'),
|
||||
'value' => 'regular',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
@@ -1514,30 +842,6 @@ class SetupDevEnvironment extends Command
|
||||
'name' => 'billing_vat_number',
|
||||
'value' => '41241241234',
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_registration_bonus',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'registration_bonus_amount',
|
||||
'value' => 10,
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_paypal',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_paystack',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_stripe',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'subscription_type',
|
||||
'value' => 'none',
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_recaptcha',
|
||||
'value' => 0,
|
||||
|
||||
@@ -5,7 +5,6 @@ use App\Users\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Domain\Pages\Actions\SeedDefaultPagesAction;
|
||||
use Domain\Settings\Actions\SeedDefaultSettingsAction;
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageAction;
|
||||
use Domain\SetupWizard\Actions\CreateDiskDirectoriesAction;
|
||||
@@ -17,7 +16,7 @@ class SetupProdEnvironment extends Command
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
protected $signature = 'setup:prod {license=extended}';
|
||||
protected $signature = 'setup:prod';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -30,7 +29,6 @@ class SetupProdEnvironment extends Command
|
||||
private CreateDiskDirectoriesAction $createDiskDirectories,
|
||||
private SeedDefaultSettingsAction $seedDefaultSettings,
|
||||
private SeedDefaultLanguageAction $seedDefaultLanguage,
|
||||
private SeedDefaultPagesAction $seedDefaultPages,
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->setUpFaker();
|
||||
@@ -54,7 +52,6 @@ class SetupProdEnvironment extends Command
|
||||
$this->info('Storing default settings and content...');
|
||||
$this->store_default_settings();
|
||||
|
||||
($this->seedDefaultPages)();
|
||||
($this->seedDefaultSettings)($this->argument('license'));
|
||||
($this->seedDefaultLanguage)();
|
||||
|
||||
@@ -129,14 +126,6 @@ class SetupProdEnvironment extends Command
|
||||
'name' => 'contact_email',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'registration',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'user_verification',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => 1,
|
||||
@@ -145,17 +134,13 @@ class SetupProdEnvironment extends Command
|
||||
'name' => 'default_max_storage_amount',
|
||||
'value' => 5,
|
||||
],
|
||||
[
|
||||
'name' => 'default_max_team_member',
|
||||
'value' => 10,
|
||||
],
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $this->argument('license'),
|
||||
'value' => 'regular',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
@@ -203,20 +188,6 @@ class SetupProdEnvironment extends Command
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
if ($this->argument('license') === 'extended') {
|
||||
$choice = $this->choice('Choose subscription type', [
|
||||
'metered' => 'Metered',
|
||||
'fixed' => 'Fixed',
|
||||
'none' => 'None',
|
||||
]);
|
||||
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'subscription_type',
|
||||
], [
|
||||
'value' => $choice,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,16 +4,12 @@ namespace App\Console;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProdEnvironment;
|
||||
use Support\Scheduler\Actions\ReportUsageAction;
|
||||
use Support\Upgrading\Actions\UpdateSystemAction;
|
||||
use Support\Demo\Actions\ClearHowdyDemoDataAction;
|
||||
use App\Console\Commands\SetupWebsocketEnvironment;
|
||||
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
||||
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
||||
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
|
||||
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
@@ -26,10 +22,6 @@ class Kernel extends ConsoleKernel
|
||||
// Basic demo content generator
|
||||
SetupDevEnvironment::class,
|
||||
SetupProdEnvironment::class,
|
||||
SetupWebsocketEnvironment::class,
|
||||
|
||||
// Subscription demo generator
|
||||
GenerateDemoSubscriptionContentCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -53,10 +45,6 @@ class Kernel extends ConsoleKernel
|
||||
fn () => resolve(DeleteExpiredShareLinksAction::class)()
|
||||
)->everyTenMinutes();
|
||||
|
||||
$schedule->call(
|
||||
fn () => resolve(ExpireUnfilledUploadRequestAction::class)()
|
||||
)->hourly();
|
||||
|
||||
$schedule->call(
|
||||
fn () => resolve(UpdateSystemAction::class)()
|
||||
)->everyMinute();
|
||||
@@ -65,10 +53,6 @@ class Kernel extends ConsoleKernel
|
||||
fn () => resolve(DeleteUnverifiedUsersAction::class)()
|
||||
)->daily()->at('00:05');
|
||||
|
||||
$schedule->call(
|
||||
fn () => resolve(ReportUsageAction::class)()
|
||||
)->daily()->at('00:10');
|
||||
|
||||
// Run queue jobs every minute
|
||||
$schedule->command('queue:work --queue=high,default --max-time=300')
|
||||
->everyFiveMinutes()
|
||||
|
||||
@@ -15,7 +15,6 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Support\Middleware\PreventRequestsDuringMaintenance;
|
||||
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Domain\UploadRequest\Middleware\ProtectUploadRequestRoutes;
|
||||
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
||||
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
|
||||
|
||||
@@ -78,6 +77,5 @@ class Kernel extends HttpKernel
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'admin' => AdminCheck::class,
|
||||
'setup-wizard' => ProtectSetupWizardRoutes::class,
|
||||
'upload-request' => ProtectUploadRequestRoutes::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
if ($user?->id === $item->user_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check team member ability to access into requested item
|
||||
return $this->teamMemberGuard($item, $user, $ability);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,17 +82,4 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
return $share->user_id === $item->user_id;
|
||||
}
|
||||
|
||||
private function teamMemberGuard(Folder | File $item, ?User $user, $ability): bool
|
||||
{
|
||||
$teamFolder = $item->getLatestParent();
|
||||
|
||||
$membership = DB::table('team_folder_members')
|
||||
->where('parent_id', $teamFolder->id)
|
||||
->where('user_id', $user->id)
|
||||
->first();
|
||||
|
||||
// check existing members permission or check team folder owner privileges
|
||||
return $membership?->permission === $ability || $teamFolder->user_id === Auth::id();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Support\Listeners\SubscriptionEventSubscriber;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
@@ -25,7 +24,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $subscribe = [
|
||||
SubscriptionEventSubscriber::class,
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,10 +43,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
->middleware('api')
|
||||
->group(base_path('routes/share.php'));
|
||||
|
||||
Route::prefix('api/upload-request')
|
||||
->middleware('api')
|
||||
->group(base_path('routes/upload-request.php'));
|
||||
|
||||
Route::prefix('api/admin')
|
||||
->middleware(['api', 'auth:sanctum', 'admin'])
|
||||
->group(base_path('routes/admin.php'));
|
||||
@@ -64,10 +60,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/file.php'));
|
||||
|
||||
Route::prefix('api/teams')
|
||||
->middleware(['api'])
|
||||
->group(base_path('routes/teams.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
|
||||
@@ -12,32 +12,14 @@ use VueFileManager\Subscription\Domain\Plans\Exceptions\MeteredBillingPlanDoesnt
|
||||
|
||||
class CreateNewUserAction extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected AutoSubscribeForMeteredBillingAction $autoSubscribeForMeteredBilling,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and create a new user.
|
||||
*
|
||||
* @throws MeteredBillingPlanDoesntExist
|
||||
*/
|
||||
public function __invoke(CreateUserData $data): User
|
||||
{
|
||||
// Check if subscription metered billing plan exist
|
||||
$this->checkMeteredBillingPlan($data);
|
||||
|
||||
// Create user
|
||||
$user = $this->createUser($data);
|
||||
|
||||
// Join to previously accepted team folder invitations
|
||||
$this->applyExistingTeamInvitations($user);
|
||||
|
||||
// Subscribe user for metered billing
|
||||
if (get_settings('subscription_type') === 'metered' && $data->role !== 'admin') {
|
||||
($this->autoSubscribeForMeteredBilling)($user);
|
||||
}
|
||||
|
||||
// Mark as verified if verification is disabled
|
||||
if (! $data->password || ! intval(get_settings('user_verification'))) {
|
||||
$user->markEmailAsVerified();
|
||||
@@ -48,43 +30,10 @@ class CreateNewUserAction extends Controller
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MeteredBillingPlanDoesntExist
|
||||
*/
|
||||
private function checkMeteredBillingPlan(CreateUserData $data): void
|
||||
{
|
||||
if (get_settings('subscription_type') === 'metered' && $data->role !== 'admin') {
|
||||
// Get metered plan
|
||||
$plan = Plan::where('status', 'active')
|
||||
->where('type', 'metered');
|
||||
|
||||
if ($plan->doesntExist()) {
|
||||
throw new MeteredBillingPlanDoesntExist();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function applyExistingTeamInvitations(User $user): void
|
||||
{
|
||||
TeamFolderInvitation::where('email', $user->email)
|
||||
->where('status', 'waiting-for-registration')
|
||||
->cursor()
|
||||
->each(function ($invitation) use ($user) {
|
||||
TeamFolderMember::create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $invitation->parent_id,
|
||||
'permission' => $invitation->permission,
|
||||
]);
|
||||
|
||||
$invitation->accept();
|
||||
});
|
||||
}
|
||||
|
||||
private function createUser(CreateUserData $data): User
|
||||
{
|
||||
$user = User::create([
|
||||
'password' => $data->password ? bcrypt($data->password) : null,
|
||||
'oauth_provider' => $data->oauth_provider,
|
||||
'email' => $data->email,
|
||||
]);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class CheckAccountController extends Controller
|
||||
'name' => $user->settings->first_name,
|
||||
'avatar' => $user->settings->avatar,
|
||||
'verified' => $user->email_verified_at ? 1 : 0,
|
||||
'oauth_provider' => $user->password ? null : $user->oauth_provider,
|
||||
'oauth_provider' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
namespace App\Users\Controllers\Authentication;
|
||||
|
||||
use App\Users\DTO\CreateUserData;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Users\Actions\CreateNewUserAction;
|
||||
use App\Users\Requests\RegisterUserRequest;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use VueFileManager\Subscription\Domain\Plans\Exceptions\MeteredBillingPlanDoesntExist;
|
||||
|
||||
class RegisterUserController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected CreateNewUserAction $createNewUser,
|
||||
protected StatefulGuard $guard,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(RegisterUserRequest $request)
|
||||
{
|
||||
// Check if account registration is enabled
|
||||
if (! intval(get_settings('registration'))) {
|
||||
return response([
|
||||
'type' => 'error',
|
||||
'message' => 'User registration is not allowed',
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Map registration data
|
||||
$data = CreateUserData::fromArray([
|
||||
'name' => $request->input('name'),
|
||||
'email' => $request->input('email'),
|
||||
'password' => $request->input('password'),
|
||||
]);
|
||||
|
||||
// Register user
|
||||
try {
|
||||
$user = ($this->createNewUser)($data);
|
||||
} catch (MeteredBillingPlanDoesntExist $e) {
|
||||
return response([
|
||||
'type' => 'error',
|
||||
'message' => 'User registrations are temporarily disabled',
|
||||
], 409);
|
||||
}
|
||||
|
||||
// Log in if verification is disabled
|
||||
if (! $user->password || ! intval(get_settings('user_verification'))) {
|
||||
$this->guard->login($user);
|
||||
}
|
||||
|
||||
return response('User successfully registered.', 201);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ class CreateUserData extends DataTransferObject
|
||||
public string $name;
|
||||
public string $email;
|
||||
public ?string $password;
|
||||
public ?string $oauth_provider;
|
||||
public ?string $avatar;
|
||||
|
||||
public static function fromRequest($request): self
|
||||
@@ -20,7 +19,6 @@ class CreateUserData extends DataTransferObject
|
||||
'email' => $request->input('email'),
|
||||
'avatar' => $request->input('avatar') ?? null,
|
||||
'password' => $request->input('password'),
|
||||
'oauth_provider' => $request->input('oauth_provider') ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -32,7 +30,6 @@ class CreateUserData extends DataTransferObject
|
||||
'email' => $array['email'],
|
||||
'avatar' => $array['avatar'] ?? null,
|
||||
'password' => $array['password'] ?? null,
|
||||
'oauth_provider' => $array['oauth_provider'] ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use App\Users\Notifications\ResetPassword;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Domain\UploadRequest\Models\UploadRequest;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\Users\Restrictions\RestrictionsManager;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
@@ -23,7 +22,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use VueFileManager\Subscription\App\User\Traits\Billable;
|
||||
|
||||
/**
|
||||
* @property string id
|
||||
@@ -47,7 +45,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
use Notifiable;
|
||||
use HasFactory;
|
||||
use Sortable;
|
||||
use Billable;
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
@@ -57,7 +54,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'password',
|
||||
'oauth_provider',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -138,8 +134,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
*/
|
||||
public function favouriteFolders(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'parent_id', 'id', 'id')
|
||||
->where('team_folder', false);
|
||||
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'parent_id', 'id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,11 +177,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return $this->hasMany(Traffic::class);
|
||||
}
|
||||
|
||||
public function uploadRequest(): HasOne
|
||||
{
|
||||
return $this->hasOne(UploadRequest::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*/
|
||||
@@ -216,7 +206,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
// Create default limitations
|
||||
$user->limitations()->create([
|
||||
'max_storage_amount' => get_settings('default_max_storage_amount') ?? 1,
|
||||
'max_team_members' => get_settings('default_max_team_member') ?? 10,
|
||||
]);
|
||||
|
||||
// Create user directory for his files
|
||||
|
||||
@@ -46,7 +46,6 @@ class UserLimitation extends Model
|
||||
{
|
||||
return [
|
||||
'max_storage_amount' => $this->getMaxStorageAmount(),
|
||||
'max_team_members' => $this->getMaxTeamMembers(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -63,44 +62,4 @@ class UserLimitation extends Model
|
||||
'percentage' => get_storage_percentage($userCapacity, $this->max_storage_amount),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get usage data of team members
|
||||
*/
|
||||
private function getMaxTeamMembers(): array
|
||||
{
|
||||
$userTeamFolderIds = DB::table('team_folder_members')
|
||||
->where('user_id', $this->user_id)
|
||||
->pluck('parent_id');
|
||||
|
||||
$memberIds = DB::table('team_folder_members')
|
||||
->where('user_id', '!=', $this->user_id)
|
||||
->whereIn('parent_id', $userTeamFolderIds)
|
||||
->pluck('user_id')
|
||||
->unique();
|
||||
|
||||
// Get member emails
|
||||
$memberEmails = User::whereIn('id', $memberIds)
|
||||
->pluck('email');
|
||||
|
||||
// Get active invitation emails
|
||||
$InvitationEmails = DB::table('team_folder_invitations')
|
||||
->where('status', 'pending')
|
||||
->where('inviter_id', $this->user_id)
|
||||
->pluck('email')
|
||||
->unique();
|
||||
|
||||
// Get allowed emails in the limit
|
||||
$totalUsedEmails = $memberEmails->merge($InvitationEmails)
|
||||
->unique();
|
||||
|
||||
return [
|
||||
'use' => $totalUsedEmails->count(),
|
||||
'total' => (int) $this->max_team_members,
|
||||
'percentage' => ($totalUsedEmails->count() / $this->max_team_members) * 100,
|
||||
'meta' => [
|
||||
'allowed_emails' => $totalUsedEmails,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,6 @@ namespace App\Users\Resources;
|
||||
|
||||
use Domain\Folders\Resources\FolderCollection;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Users\Actions\FormatUsageEstimatesAction;
|
||||
use Domain\Notifications\Resources\NotificationCollection;
|
||||
use VueFileManager\Subscription\Domain\Credits\Resources\BalanceResource;
|
||||
use VueFileManager\Subscription\Domain\CreditCards\Resources\CreditCardCollection;
|
||||
use VueFileManager\Subscription\Domain\BillingAlerts\Resources\BillingAlertResource;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Resources\SubscriptionResource;
|
||||
use VueFileManager\Subscription\Domain\Usage\Actions\SumUsageForCurrentPeriodAction;
|
||||
use VueFileManager\Subscription\Domain\FailedPayments\Resources\FailedPaymentsCollection;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
@@ -22,11 +14,6 @@ class UserResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$subscriptionType = get_settings('subscription_type');
|
||||
|
||||
$isMeteredSubscription = $subscriptionType === 'metered';
|
||||
$isFixedSubscription = $subscriptionType === 'fixed';
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
@@ -44,63 +31,17 @@ class UserResource extends JsonResource
|
||||
'updated_at' => format_date($this->updated_at, 'd. M. Y'),
|
||||
],
|
||||
'relationships' => [
|
||||
'readNotifications' => new NotificationCollection($this->readNotifications),
|
||||
'unreadNotifications' => new NotificationCollection($this->unreadNotifications),
|
||||
'settings' => new SettingsResource($this->settings),
|
||||
'favourites' => new FolderCollection($this->favouriteFolders),
|
||||
'creditCards' => new CreditCardCollection($this->creditCards),
|
||||
$this->mergeWhen($this->hasSubscription(), fn () => [
|
||||
'subscription' => new SubscriptionResource($this->subscription),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'balance' => new BalanceResource($this->balance),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'alert' => new BillingAlertResource($this->billingAlert),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'failedPayments' => new FailedPaymentsCollection($this->failedPayments),
|
||||
]),
|
||||
],
|
||||
'meta' => [
|
||||
'restrictions' => [
|
||||
'canUpload' => $this->canUpload(),
|
||||
'canDownload' => $this->canDownload(),
|
||||
'canCreateFolder' => $this->canCreateFolder(),
|
||||
'canCreateTeamFolder' => $this->canCreateTeamFolder(),
|
||||
'canInviteTeamMembers' => $this->canInviteTeamMembers(),
|
||||
],
|
||||
$this->mergeWhen($isFixedSubscription, fn () => [
|
||||
'limitations' => $this->limitations->summary(),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'usages' => $this->getUsageEstimates(),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'totalDebt' => [
|
||||
'formatted' => format_currency($this->failedPayments->sum('amount'), $this->subscription->plan->currency),
|
||||
'amount' => $this->failedPayments->sum('amount'),
|
||||
],
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getUsageEstimates()
|
||||
{
|
||||
// Get plan currency
|
||||
$currency = $this->subscription->plan->currency;
|
||||
|
||||
// Get usage
|
||||
$usage = resolve(SumUsageForCurrentPeriodAction::class)($this->subscription);
|
||||
|
||||
// Format usages
|
||||
$estimates = resolve(FormatUsageEstimatesAction::class)($currency, $usage);
|
||||
|
||||
return [
|
||||
'costEstimate' => format_currency($estimates->sum('amount'), $currency),
|
||||
'featureEstimates' => $estimates->toArray(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,7 @@ class UserStorageResource extends JsonResource
|
||||
list($images, $audios, $videos, $documents, $others) = $this->get_file_type_distribution();
|
||||
list($downloadTotal, $uploadTotal, $upload, $download) = $this->get_traffic_distribution();
|
||||
|
||||
$totalCapacity = match (get_settings('subscription_type')) {
|
||||
'metered' => $this->usedCapacity / 1000000000,
|
||||
'fixed' => $this->limitations->max_storage_amount,
|
||||
default => $this->limitations->max_storage_amount,
|
||||
};
|
||||
$totalCapacity = $this->limitations->max_storage_amount;
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
|
||||
@@ -33,16 +33,6 @@ class DefaultRestrictionsEngine implements RestrictionsEngine
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canCreateTeamFolder(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canInviteTeamMembers(User $user, array $newInvites = []): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canVisitShared(User $user): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -11,9 +11,5 @@ interface RestrictionsEngine
|
||||
|
||||
public function canCreateFolder(User $user): bool;
|
||||
|
||||
public function canCreateTeamFolder(User $user): bool;
|
||||
|
||||
public function canInviteTeamMembers(User $user, array $newInvites = []): bool;
|
||||
|
||||
public function canVisitShared(User $user): bool;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ namespace App\Users\Restrictions;
|
||||
|
||||
use Illuminate\Support\Manager;
|
||||
use App\Users\Restrictions\Engines\DefaultRestrictionsEngine;
|
||||
use App\Users\Restrictions\Engines\FixedBillingRestrictionsEngine;
|
||||
use App\Users\Restrictions\Engines\MeteredBillingRestrictionsEngine;
|
||||
|
||||
class RestrictionsManager extends Manager
|
||||
{
|
||||
|
||||
@@ -21,11 +21,6 @@ class DeleteUserDataAction
|
||||
// Delete all user files
|
||||
Storage::deleteDirectory("files/$user->id");
|
||||
|
||||
// Delete user subscriptions
|
||||
if ($user->subscription) {
|
||||
$user->subscription->delete();
|
||||
}
|
||||
|
||||
// Delete all user records in database
|
||||
collect(['folders', 'files', 'user_settings', 'shares', 'favourite_folder', 'traffic'])
|
||||
->each(function ($table) use ($user) {
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Users\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
||||
|
||||
class GetDashboardDataController extends Controller
|
||||
{
|
||||
@@ -15,16 +14,9 @@ class GetDashboardDataController extends Controller
|
||||
// Get bandwidth data
|
||||
list($upload, $download, $uploadTotal, $downloadTotal, $storageUsage) = $this->getDiskData();
|
||||
|
||||
// Get total earnings from transactions
|
||||
$totalEarnings = DB::table('transactions')
|
||||
->where('status', 'completed')
|
||||
->where('type', 'charge')
|
||||
->sum('amount');
|
||||
|
||||
return response()->json([
|
||||
'users' => [
|
||||
'total' => User::count(),
|
||||
'usersPremiumTotal' => Subscription::count(),
|
||||
],
|
||||
'disk' => [
|
||||
'used' => $storageUsage,
|
||||
@@ -41,7 +33,6 @@ class GetDashboardDataController extends Controller
|
||||
'isRunningCron' => isRunningCron(),
|
||||
'license' => get_settings('license'),
|
||||
'version' => config('vuefilemanager.version'),
|
||||
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup or plan currency
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ class BrowseFolderController
|
||||
|
||||
$folders = Folder::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('parent_id', $root_id)
|
||||
->where('team_folder', false)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
@@ -53,18 +53,12 @@ class SpotlightSearchController
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get "shared with me" folders
|
||||
$sharedWithMeFolderIds = DB::table('team_folder_members')
|
||||
->where('user_id', $user_id)
|
||||
->pluck('parent_id');
|
||||
|
||||
// Next get their folder tree for ids extraction
|
||||
$folderWithinIds = Folder::with('folders:id,parent_id')
|
||||
->whereIn('parent_id', $sharedWithMeFolderIds)
|
||||
->get(['id']);
|
||||
|
||||
// Then get all accessible shared folders within
|
||||
$accessible_parent_ids = Arr::flatten([filter_folders_ids($folderWithinIds), $sharedWithMeFolderIds]);
|
||||
$accessible_parent_ids = Arr::flatten([filter_folders_ids($folderWithinIds)]);
|
||||
|
||||
// Prepare eloquent builder
|
||||
$folder = new Folder();
|
||||
|
||||
@@ -60,19 +60,10 @@ class GetFileParentId
|
||||
|
||||
private function createFolder($directoryName, $userId, $parentId): Folder
|
||||
{
|
||||
/*
|
||||
* Check if exist parent team folder, if yes,
|
||||
* then get the latest parent folder to detect whether it is team_folder
|
||||
*/
|
||||
if ($parentId) {
|
||||
$isTeamFolder = Folder::find($parentId)->getLatestParent()->team_folder;
|
||||
}
|
||||
|
||||
return Folder::create([
|
||||
'name' => $directoryName,
|
||||
'parent_id' => $parentId,
|
||||
'user_id' => $userId,
|
||||
'team_folder' => $isTeamFolder ?? false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
35
src/Domain/Files/Requests/UploadRequest.php
Normal file
35
src/Domain/Files/Requests/UploadRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Domain\Files\Requests;
|
||||
|
||||
use Domain\Admin\Rules\DisabledMimetypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UploadRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'parent_id' => 'nullable|uuid',
|
||||
'path' => 'required|string',
|
||||
'is_last' => 'sometimes|string',
|
||||
'extension' => 'sometimes|string|nullable',
|
||||
'file' => ['required', 'file', new DisabledMimetypes],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,6 @@ class CreateFolderAction
|
||||
'emoji' => $request->input('emoji') ?? null,
|
||||
'author' => $shared ? 'visitor' : 'user',
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => $isFilledParentId
|
||||
? Folder::find($parentId)->getLatestParent()->team_folder
|
||||
: false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,30 +10,10 @@ class NavigationTreeController
|
||||
public function __invoke(): array
|
||||
{
|
||||
// Get signed user folders
|
||||
$folders = Folder::with('folders:id,parent_id,name,team_folder')
|
||||
$folders = Folder::with('folders:id,parent_id,name')
|
||||
->where('parent_id')
|
||||
->where('team_folder', false)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'name', 'team_folder']);
|
||||
|
||||
// Get signed user team folders
|
||||
$teamFolders = Folder::with('folders:id,parent_id,name,team_folder')
|
||||
->where('parent_id')
|
||||
->where('team_folder', true)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'name']);
|
||||
|
||||
// Get signed user folder which are shared with him
|
||||
$sharedFolderIds = DB::table('team_folder_members')
|
||||
->where('user_id', Auth::id())
|
||||
->whereIn('permission', ['can-edit', 'can-view'])
|
||||
->pluck('parent_id');
|
||||
|
||||
$sharedWithMeFolders = Folder::with('folders:id,parent_id,name,team_folder')
|
||||
->whereIn('id', $sharedFolderIds)
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'name']);
|
||||
|
||||
return [
|
||||
@@ -44,20 +24,6 @@ class NavigationTreeController
|
||||
'isMovable' => true,
|
||||
'isOpen' => true,
|
||||
],
|
||||
[
|
||||
'location' => 'team-folders',
|
||||
'name' => __t('team_folders'),
|
||||
'folders' => $teamFolders,
|
||||
'isMovable' => false,
|
||||
'isOpen' => false,
|
||||
],
|
||||
[
|
||||
'location' => 'shared-with-me',
|
||||
'name' => __t('shared_with_me'),
|
||||
'folders' => $sharedWithMeFolders,
|
||||
'isMovable' => false,
|
||||
'isOpen' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ use Kyslik\ColumnSortable\Sortable;
|
||||
use Database\Factories\FolderFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use Domain\Teams\Models\TeamFolderInvitation;
|
||||
use \Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
* @property string deleted_at
|
||||
* @property bool team_folder
|
||||
*/
|
||||
class Folder extends Model
|
||||
{
|
||||
@@ -54,7 +52,6 @@ class Folder extends Model
|
||||
|
||||
protected $casts = [
|
||||
'emoji' => 'array',
|
||||
'team_folder' => 'boolean',
|
||||
];
|
||||
|
||||
public $sortable = [
|
||||
@@ -180,18 +177,6 @@ class Folder extends Model
|
||||
return $this->hasOne(Share::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function teamInvitations(): HasMany
|
||||
{
|
||||
return $this->hasMany(TeamFolderInvitation::class, 'parent_id', 'id')
|
||||
->where('status', 'pending');
|
||||
}
|
||||
|
||||
public function teamMembers(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'team_folder_members', 'parent_id', 'user_id')
|
||||
->withPivot('permission');
|
||||
}
|
||||
|
||||
public function user(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
|
||||
@@ -19,7 +19,7 @@ class FolderResource extends JsonResource
|
||||
'color' => $this->color,
|
||||
'emoji' => $this->emoji,
|
||||
'filesize' => $this->filesize,
|
||||
'isTeamFolder' => $this->team_folder,
|
||||
'isTeamFolder' => false,
|
||||
'items' => $this->items,
|
||||
'trashed_items' => $this->trashed_items,
|
||||
'created_at' => set_time_by_user_timezone($this->user, $this->created_at),
|
||||
@@ -29,12 +29,6 @@ class FolderResource extends JsonResource
|
||||
: null,
|
||||
],
|
||||
'relationships' => [
|
||||
$this->mergeWhen($this->teamMembers, fn () => [
|
||||
'members' => new TeamMembersCollection($this->teamMembers),
|
||||
]),
|
||||
$this->mergeWhen($this->teamInvitations, fn () => [
|
||||
'invitations' => new TeamInvitationsCollection($this->teamInvitations),
|
||||
]),
|
||||
$this->mergeWhen($this->shared, fn () => [
|
||||
'shared' => new ShareResource($this->shared),
|
||||
]),
|
||||
@@ -49,19 +43,6 @@ class FolderResource extends JsonResource
|
||||
],
|
||||
],
|
||||
]),
|
||||
$this->mergeWhen($this->user, fn () => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'type' => 'user',
|
||||
'id' => $this->user_id,
|
||||
'attributes' => [
|
||||
'name' => $this->user->settings->name,
|
||||
'avatar' => $this->user->settings->avatar,
|
||||
'color' => $this->user->settings->color,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -30,9 +30,6 @@ class IndexController
|
||||
// Get setup status
|
||||
$setup_status = get_setup_status();
|
||||
|
||||
// Get app pages
|
||||
$pages = Page::all();
|
||||
|
||||
// Get all settings
|
||||
$settings = get_settings_in_json();
|
||||
} catch (PDOException $e) {
|
||||
@@ -45,7 +42,6 @@ class IndexController
|
||||
return view('index')
|
||||
->with('status_check', $status_check ?? [])
|
||||
->with('settings', $settings ?? null)
|
||||
->with('legal', $pages ?? null)
|
||||
->with('installation', $setup_status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,9 @@ namespace Domain\Items\Actions;
|
||||
|
||||
use Gate;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\Teams\Actions\SetTeamFolderPropertyForAllChildrenAction;
|
||||
|
||||
class MoveFileOrFolderAction
|
||||
{
|
||||
public function __construct(
|
||||
public SetTeamFolderPropertyForAllChildrenAction $setTeamFolderPropertyForAllChildren,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Move folder or file to new location
|
||||
*/
|
||||
@@ -24,30 +17,10 @@ class MoveFileOrFolderAction
|
||||
// Check permission
|
||||
Gate::authorize('can-edit', [$entry, $share]);
|
||||
|
||||
// Process folder
|
||||
if ($item['type'] === 'folder') {
|
||||
// Determine, if we are moving folder into the team folder or not
|
||||
$isTeamFolder = is_null($request->input('to_id'))
|
||||
? false
|
||||
: Folder::find($request->input('to_id'))->getLatestParent()->team_folder;
|
||||
|
||||
// Change team_folder mark for all children folders
|
||||
($this->setTeamFolderPropertyForAllChildren)($entry, $isTeamFolder);
|
||||
|
||||
// Update folder
|
||||
$entry->update([
|
||||
'parent_id' => $request->input('to_id'),
|
||||
'team_folder' => $isTeamFolder,
|
||||
]);
|
||||
}
|
||||
|
||||
// Process file
|
||||
if ($item['type'] !== 'folder') {
|
||||
// Update file
|
||||
$entry->update([
|
||||
'parent_id' => $request->input('to_id'),
|
||||
]);
|
||||
}
|
||||
// Update item
|
||||
$entry->update([
|
||||
'parent_id' => $request->input('to_id'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,10 @@ class SeedDefaultSettingsAction
|
||||
/**
|
||||
* Store default VueFileManager settings into database
|
||||
*/
|
||||
public function __invoke(
|
||||
string $license
|
||||
): void {
|
||||
public function __invoke(): void {
|
||||
// Set default settings
|
||||
collect(
|
||||
config('content.content.' . strtolower($license))
|
||||
config('content.content.regular')
|
||||
)->each(fn ($content) => Setting::updateOrCreate([
|
||||
'name' => $content['name'],
|
||||
], [
|
||||
@@ -23,6 +21,6 @@ class SeedDefaultSettingsAction
|
||||
|
||||
// Set update records
|
||||
collect(config('vuefilemanager.updates'))
|
||||
->each(fn ($version) => AppUpdate::create(['version' => $version]));
|
||||
->each(fn ($version) => AppUpdate::create(['version' => 'regular']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,21 +29,6 @@ class UpdateSettingValueController extends Controller
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
// Set paypal live option
|
||||
if ($request->input('name') === 'paypal_live') {
|
||||
setEnvironmentValue([
|
||||
'PAYPAL_IS_LIVE' => $request->input('value') ? 'true' : 'false',
|
||||
]);
|
||||
|
||||
// Clear config cache
|
||||
if (! is_dev()) {
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
// Find and update variable
|
||||
Setting::updateOrCreate(
|
||||
['name' => $request->input('name')],
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use DB;
|
||||
use Artisan;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Domain\Localization\Models\Language;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Domain\Settings\Requests\UpgradeLicenseRequest;
|
||||
|
||||
class UpgradeLicenseController extends Controller
|
||||
{
|
||||
public function __invoke(UpgradeLicenseRequest $request): Response|Application|ResponseFactory
|
||||
{
|
||||
// Verify purchase code
|
||||
$response = Http::get("https://verify.vuefilemanager.com/api/verify-code/{$request->input('purchaseCode')}");
|
||||
|
||||
if ($response->successful() && $response->body() === 'b6896a44017217c36f4a6fdc56699728') {
|
||||
// Store default settings for extended version
|
||||
collect([
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => 'extended',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => $request->input('purchaseCode'),
|
||||
],
|
||||
[
|
||||
'name' => 'section_pricing_content',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'paypal_payment_description',
|
||||
'value' => 'Available PayPal Credit, Debit or Credit Card.',
|
||||
],
|
||||
[
|
||||
'name' => 'paystack_payment_description',
|
||||
'value' => 'Available Bank Account, USSD, Mobile Money, Apple Pay.',
|
||||
],
|
||||
[
|
||||
'name' => 'stripe_payment_description',
|
||||
'value' => 'Available credit card or Apple Pay.',
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_registration_bonus',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'registration_bonus_amount',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_title',
|
||||
'value' => 'Pick the <span class="text-theme">Best Plan</span> For Your Needs',
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $col['name'],
|
||||
], [
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Seed translations for extended version
|
||||
Language::all()
|
||||
->each(function ($lang) {
|
||||
$translations = collect(
|
||||
config('language-translations.extended')
|
||||
)
|
||||
->map(fn ($value, $key) => [
|
||||
'lang' => $lang->locale,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
])->toArray();
|
||||
|
||||
$chunks = array_chunk($translations, 100);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
DB::table('language_translations')
|
||||
->insert($chunk);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear config and cache
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return response('Your license was successfully upgraded', 201);
|
||||
}
|
||||
|
||||
return response('Purchase code is invalid or is not Extended License.', 400);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use Illuminate\Http\Response;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Domain\Pages\Actions\SeedDefaultPagesAction;
|
||||
use Domain\Settings\Actions\SeedDefaultSettingsAction;
|
||||
use Domain\SetupWizard\Requests\StoreAdminAccountRequest;
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageAction;
|
||||
@@ -20,7 +19,6 @@ class CreateAdminAccountController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected StatefulGuard $guard,
|
||||
public SeedDefaultPagesAction $seedDefaultPages,
|
||||
public SeedDefaultLanguageAction $seedDefaultLanguage,
|
||||
public CreateDiskDirectoriesAction $createDiskDirectories,
|
||||
public SeedDefaultSettingsAction $seedDefaultSettingsAction,
|
||||
@@ -58,7 +56,7 @@ class CreateAdminAccountController extends Controller
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => strtolower($request->input('license')),
|
||||
'value' => 'regular',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
@@ -79,8 +77,7 @@ class CreateAdminAccountController extends Controller
|
||||
Artisan::call('config:clear');
|
||||
|
||||
// Set up application
|
||||
($this->seedDefaultPages)();
|
||||
($this->seedDefaultSettingsAction)($request->input('license'));
|
||||
($this->seedDefaultSettingsAction)();
|
||||
($this->seedDefaultLanguage)();
|
||||
|
||||
return response('Registration was successful', 204);
|
||||
|
||||
@@ -16,10 +16,6 @@ class StoreAppSettingsController extends Controller
|
||||
StoreAppSetupRequest $request
|
||||
): Response {
|
||||
collect([
|
||||
[
|
||||
'name' => 'subscription_type',
|
||||
'value' => $request->input('subscriptionType') ?? 'none',
|
||||
],
|
||||
[
|
||||
'name' => 'app_color',
|
||||
'value' => $request->input('color'),
|
||||
@@ -68,10 +64,6 @@ class StoreAppSettingsController extends Controller
|
||||
'name' => 'contact_email',
|
||||
'value' => $request->input('contactMail'),
|
||||
],
|
||||
[
|
||||
'name' => 'registration',
|
||||
'value' => $request->input('userRegistration'),
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => $request->input('storageLimitation'),
|
||||
@@ -80,14 +72,6 @@ class StoreAppSettingsController extends Controller
|
||||
'name' => 'default_max_storage_amount',
|
||||
'value' => $request->input('defaultStorage') ?? 5,
|
||||
],
|
||||
[
|
||||
'name' => 'default_max_team_member',
|
||||
'value' => $request->input('teamsDefaultMembers') ?? 10,
|
||||
],
|
||||
[
|
||||
'name' => 'user_verification',
|
||||
'value' => 0,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $col['name'],
|
||||
|
||||
@@ -83,31 +83,6 @@ class StoreEnvironmentSettingsController extends Controller
|
||||
};
|
||||
|
||||
$setup = [
|
||||
'broadcasting' => [
|
||||
'pusher' => [
|
||||
'BROADCAST_DRIVER' => 'pusher',
|
||||
'PUSHER_APP_ID' => $request->input('broadcast.id'),
|
||||
'PUSHER_APP_KEY' => $request->input('broadcast.key'),
|
||||
'PUSHER_APP_SECRET' => $request->input('broadcast.secret'),
|
||||
'PUSHER_APP_CLUSTER' => $request->input('broadcast.cluster'),
|
||||
'PUSHER_APP_HOST' => '',
|
||||
'PUSHER_APP_PORT' => '',
|
||||
'PUSHER_APP_TLS' => true,
|
||||
],
|
||||
'native' => [
|
||||
'BROADCAST_DRIVER' => 'pusher',
|
||||
'PUSHER_APP_ID' => 'local',
|
||||
'PUSHER_APP_KEY' => 'local',
|
||||
'PUSHER_APP_SECRET' => 'local',
|
||||
'PUSHER_APP_CLUSTER' => 'local',
|
||||
'PUSHER_APP_HOST' => $request->input('broadcast.host'),
|
||||
'PUSHER_APP_PORT' => '',
|
||||
'PUSHER_APP_TLS' => $request->boolean('tls') ? 'true' : 'false',
|
||||
],
|
||||
'none' => [
|
||||
'BROADCAST_DRIVER' => 'null',
|
||||
],
|
||||
],
|
||||
'drivers' => [
|
||||
'local' => [
|
||||
'FILESYSTEM_DISK' => 'local',
|
||||
@@ -184,7 +159,6 @@ class StoreEnvironmentSettingsController extends Controller
|
||||
|
||||
// Set other environment variables
|
||||
setEnvironmentValue(array_merge(
|
||||
$setup['broadcasting'][$request->input('broadcast.driver')],
|
||||
$setup['environment'][$request->input('environment')],
|
||||
$setup['mail'][$request->input('mailDriver')],
|
||||
$setup['drivers'][$StorageDriver],
|
||||
|
||||
@@ -27,7 +27,6 @@ class StoreAdminAccountRequest extends FormRequest
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'name' => 'required|string',
|
||||
'purchase_code' => 'required|string',
|
||||
'license' => 'required|string',
|
||||
'avatar' => 'sometimes|file',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ class StoreAppSetupRequest extends FormRequest
|
||||
'contactMail' => 'required|email',
|
||||
'googleAnalytics' => 'sometimes|string',
|
||||
'defaultStorage' => 'sometimes|digits_between:1,9',
|
||||
'userRegistration' => 'required|boolean',
|
||||
'storageLimitation' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ class StoreEnvironmentSetupRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'broadcast' => 'required|array',
|
||||
'storage' => 'required|array',
|
||||
'environment' => 'required|string',
|
||||
'storage.driver' => 'required|string',
|
||||
|
||||
@@ -17,14 +17,5 @@ class ClearHowdyDemoDataAction
|
||||
DB::table('shares')
|
||||
->where('user_id', $user->id)
|
||||
->delete();
|
||||
|
||||
// Delete File request
|
||||
UploadRequest::where('user_id', $user->id)
|
||||
->cursor()
|
||||
->each(function ($request) {
|
||||
if ($request->created_at->diffInHours(now()) >= 6) {
|
||||
$request->delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,119 +19,5 @@ class UpgradingVersionsController
|
||||
public UpgradeDatabaseAction $upgradeDatabase,
|
||||
public DeleteLanguageTranslationsAction $deleteLanguageStrings,
|
||||
public UpdateLanguageTranslationsAction $updateLanguageStrings,
|
||||
) {
|
||||
}
|
||||
|
||||
public function upgrade_to_2_1_1(): void
|
||||
{
|
||||
($this->upgradeDatabase)();
|
||||
}
|
||||
|
||||
public function upgrade_to_2_0_10(): void
|
||||
{
|
||||
($this->upgradeDatabase)();
|
||||
|
||||
// Upgrade team folder content ownership
|
||||
Folder::where('parent_id', null)
|
||||
->where('team_folder', true)
|
||||
->cursor()
|
||||
->each(function ($teamFolder) {
|
||||
// Get all inherited folder from team folder
|
||||
$childrenFolderIds = Folder::with('folders:id,parent_id')
|
||||
->where('id', $teamFolder->id)
|
||||
->get('id');
|
||||
|
||||
$teamFolderIds = Arr::flatten(filter_folders_ids($childrenFolderIds));
|
||||
|
||||
// Replace user content ownership for author of team folder
|
||||
DB::table('files')
|
||||
->whereIn('parent_id', $teamFolderIds)
|
||||
->cursor()
|
||||
->each(function ($file) use ($teamFolder) {
|
||||
// Move image thumbnails
|
||||
if ($file->type === 'image') {
|
||||
// Get image thumbnail list
|
||||
$thumbnailList = getThumbnailFileList($file->basename);
|
||||
|
||||
// move thumbnails to the new location
|
||||
$thumbnailList->each(function ($basename) use ($file, $teamFolder) {
|
||||
$oldPath = "files/$file->user_id/$basename";
|
||||
$newPath = "files/$teamFolder->user_id/$basename";
|
||||
|
||||
if (Storage::exists($oldPath)) {
|
||||
Storage::move($oldPath, $newPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get single file path
|
||||
$filePath = "files/$file->user_id/$file->basename";
|
||||
|
||||
// Move single file
|
||||
if (Storage::exists($filePath)) {
|
||||
Storage::move($filePath, "files/$teamFolder->user_id/$file->basename");
|
||||
}
|
||||
|
||||
// Update file permission
|
||||
File::find($file->id)->update([
|
||||
'user_id' => $teamFolder->user_id,
|
||||
'creator_id' => $teamFolder->user_id !== $file->user_id ? $file->user_id : null,
|
||||
]);
|
||||
});
|
||||
|
||||
// Update folder ownership
|
||||
DB::table('folders')
|
||||
->whereIn('parent_id', $teamFolderIds)
|
||||
->update(['user_id' => $teamFolder->user_id]);
|
||||
});
|
||||
|
||||
// Upgrade dwg files
|
||||
File::withTrashed()
|
||||
->where('mimetype', 'vnd.dwg')
|
||||
->cursor()
|
||||
->each(fn ($file) => $file->update([
|
||||
'mimetype' => 'dwg',
|
||||
'type' => 'file',
|
||||
]));
|
||||
}
|
||||
|
||||
public function upgrade_to_2_0_13(): void
|
||||
{
|
||||
// Force plan synchronization
|
||||
if (get_settings('license') === 'extended' && Plan::count() !== 0) {
|
||||
Artisan::call('subscription:synchronize-plans');
|
||||
}
|
||||
}
|
||||
|
||||
public function upgrade_to_2_0_14(): void
|
||||
{
|
||||
($this->upgradeDatabase)();
|
||||
|
||||
User::whereNotNull('two_factor_secret')
|
||||
->cursor()
|
||||
->each(fn ($user) => $user->forceFill(['two_factor_confirmed_at' => now()])->save());
|
||||
|
||||
($this->deleteLanguageStrings)([
|
||||
'popup_2fa.disappear_qr',
|
||||
]);
|
||||
|
||||
($this->updateLanguageStrings)([
|
||||
'require_email_verification' => 'Require Verify Email Address',
|
||||
'require_email_verification_note' => 'Turn on, if you want to verify user email address after registration.',
|
||||
]);
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
}
|
||||
|
||||
public function upgrade_to_2_0_16(): void
|
||||
{
|
||||
($this->updateLanguageStrings)([
|
||||
'write_feedback' => 'Help Us Improve',
|
||||
'change_password' => 'Security & API',
|
||||
'shared.empty_shared' => 'Nothing Shared Yet',
|
||||
'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)',
|
||||
]);
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -38,16 +38,6 @@ if (! function_exists('getListOfLatestLogs')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('isBroadcasting')) {
|
||||
/**
|
||||
* Check if cron is running
|
||||
*/
|
||||
function isBroadcasting(): bool
|
||||
{
|
||||
return config('broadcasting.default') === 'pusher';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('isRunningCron')) {
|
||||
/**
|
||||
* Check if cron is running
|
||||
@@ -91,20 +81,6 @@ if (! function_exists('obfuscate_email')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_restriction_driver')) {
|
||||
/**
|
||||
* Get driver for limitation API
|
||||
*/
|
||||
function get_restriction_driver(): string
|
||||
{
|
||||
return match (get_settings('subscription_type')) {
|
||||
'fixed' => 'fixed',
|
||||
'metered' => 'metered',
|
||||
default => 'default',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_email_provider')) {
|
||||
/**
|
||||
* Get single or multiple values from settings table
|
||||
@@ -239,24 +215,6 @@ if (! function_exists('setEnvironmentValue')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_invoice_number')) {
|
||||
/**
|
||||
* Get invoice number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_invoice_number()
|
||||
{
|
||||
$invoices = \App\Invoice::all();
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
return now()->year . '001';
|
||||
}
|
||||
|
||||
return (int) $invoices->last()->order + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('cache_forget_many')) {
|
||||
/**
|
||||
* Forget many cache keys at once
|
||||
@@ -270,18 +228,6 @@ if (! function_exists('cache_forget_many')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_storage')) {
|
||||
/**
|
||||
* Get app version from config
|
||||
*
|
||||
* @return \Illuminate\Config\Repository|mixed
|
||||
*/
|
||||
function get_storage()
|
||||
{
|
||||
return config('filesystems.default');
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('isStorageDriver')) {
|
||||
/**
|
||||
* Check if is running AWS s3 as storage
|
||||
@@ -1067,29 +1013,6 @@ if (! function_exists('replace_occurrence')) {
|
||||
);
|
||||
}
|
||||
|
||||
if (! function_exists('get_socialite_avatar')) {
|
||||
/**
|
||||
* Get socialite avatar create and store his thumbnails
|
||||
*/
|
||||
function store_socialite_avatar($avatar)
|
||||
{
|
||||
// Get image from external source
|
||||
$image = Http::get($avatar)->body();
|
||||
|
||||
// Generate avatar name
|
||||
$avatar_name = Str::uuid() . '.jpg';
|
||||
|
||||
// Create intervention image
|
||||
$intervention = Image::make($image);
|
||||
|
||||
// Generate avatar sizes
|
||||
generate_avatar_thumbnails($intervention, $avatar_name);
|
||||
|
||||
// Return name of image
|
||||
return $avatar_name;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('generate_avatar_thumbnails')) {
|
||||
/**
|
||||
* Create avatar thumbnails
|
||||
@@ -1124,39 +1047,4 @@ if (! function_exists('replace_occurrence')) {
|
||||
return "{$degrees}°$minutes'$seconds\"$ref";
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('extractExtensionFromUrl')) {
|
||||
/**
|
||||
* Extract extension from the url
|
||||
*
|
||||
* TODO: make unit test
|
||||
*/
|
||||
function extractExtensionFromUrl($url, $response): string|null
|
||||
{
|
||||
$extension = null;
|
||||
|
||||
if (array_key_exists('extension', pathinfo($url))) {
|
||||
// Break attributes
|
||||
$string = str_replace(['&'], '?', pathinfo($url)['extension']);
|
||||
|
||||
// Get extension from url path
|
||||
$extension = explode('?', $string)[0];
|
||||
}
|
||||
|
||||
// Return pure extension
|
||||
if ($extension) {
|
||||
return $extension;
|
||||
}
|
||||
|
||||
// Prepare header for extracting content-type line
|
||||
$header = array_change_key_case($response->headers(), CASE_LOWER);
|
||||
|
||||
// Get extension
|
||||
if (array_key_exists('content-type', $header)) {
|
||||
return explode('/', $header['content-type'][0])[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user