diff --git a/composer.json b/composer.json index 3ba921c8..31004750 100644 --- a/composer.json +++ b/composer.json @@ -98,7 +98,6 @@ "post-create-project-cmd": [ "@php artisan key:generate --ansi" ], - "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", - "psalm": "vendor/bin/psalm" + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" } } diff --git a/composer.lock b/composer.lock index f94d2c2d..320eebe5 100644 --- a/composer.lock +++ b/composer.lock @@ -5279,16 +5279,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.8", + "version": "9.2.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e" + "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", - "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", "shasum": "" }, "require": { @@ -5344,7 +5344,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.8" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" }, "funding": [ { @@ -5352,7 +5352,7 @@ "type": "github" } ], - "time": "2021-10-30T08:01:38+00:00" + "time": "2021-11-19T15:21:02+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 7171e47f..c3827d18 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -48,7 +48,7 @@ class UserFactory extends Factory $user ->settings() ->create([ - 'storage_capacity' => $this->faker->randomNumber(1), + 'max_storage_amount' => $this->faker->randomNumber(1), 'name' => $this->faker->name, 'address' => $this->faker->address, 'state' => $this->faker->state, diff --git a/database/migrations/2020_05_26_092649_create_user_settings_table.php b/database/migrations/2020_05_26_092649_create_user_settings_table.php index 4b92ff6e..69083d62 100644 --- a/database/migrations/2020_05_26_092649_create_user_settings_table.php +++ b/database/migrations/2020_05_26_092649_create_user_settings_table.php @@ -15,7 +15,7 @@ class CreateUserSettingsTable extends Migration { Schema::create('user_settings', function (Blueprint $table) { $table->uuid('user_id')->index(); - $table->integer('storage_capacity')->default(5); + $table->integer('max_storage_amount')->default(5); $table->string('avatar')->nullable(); $table->string('color')->nullable(); $table->text('name')->nullable(); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 4ab8d9ce..9c9be1c4 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -53,7 +53,7 @@ "/chunks/page-edit.js": "/chunks/page-edit.js?id=1963acc189f3f92441a6", "/chunks/pages.js": "/chunks/pages.js?id=f5c86b24fcbe15b15d1d", "/chunks/plan.js": "/chunks/plan.js?id=052940a7395f559b7c60", - "/chunks/plan-create.js": "/chunks/plan-create.js?id=d939086958e81fafdd65", + "/chunks/plan-create.js": "/chunks/plan-create.js?id=c63cea650ea78e3c3ffc", "/chunks/plan-delete.js": "/chunks/plan-delete.js?id=96f48131997a0092be4b", "/chunks/plan-settings.js": "/chunks/plan-settings.js?id=2f403063c6a896f09e17", "/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=99854b8b4518fbebc79f", @@ -90,21 +90,24 @@ "/chunks/team-folders.js": "/chunks/team-folders.js?id=0e69f4432e968cc512f9", "/chunks/trash.js": "/chunks/trash.js?id=5fe84aadd8729e68849e", "/chunks/upgrade-billing.js": "/chunks/upgrade-billing.js?id=2bffa85e82a5cda1dcd2", - "/chunks/upgrade-billing~chunks/upgrade-plan.js": "/chunks/upgrade-billing~chunks/upgrade-plan.js?id=f59d97c1cbf6649b7057", + "/chunks/upgrade-billing~chunks/upgrade-plan.js": "/chunks/upgrade-billing~chunks/upgrade-plan.js?id=8bd237c632018a537d76", "/chunks/upgrade-plan.js": "/chunks/upgrade-plan.js?id=460e6f80d824b5a93adf", "/chunks/user.js": "/chunks/user.js?id=fe26116ebc97069cf7f9", - "/chunks/user-create.js": "/chunks/user-create.js?id=f7ff89074c03e72e3d06", + "/chunks/user-create.js": "/chunks/user-create.js?id=241720b78b7309f9b319", "/chunks/user-delete.js": "/chunks/user-delete.js?id=36e7149e777f1ecd71e9", "/chunks/user-detail.js": "/chunks/user-detail.js?id=6218f429f4040d0524ac", "/chunks/user-invoices.js": "/chunks/user-invoices.js?id=386719adbd52708773ba", "/chunks/user-password.js": "/chunks/user-password.js?id=22725c9c88b862276b34", - "/chunks/user-storage.js": "/chunks/user-storage.js?id=3be3b8a695ef8b69792a", + "/chunks/user-storage.js": "/chunks/user-storage.js?id=8d46386de83e5f198c40", "/chunks/user-subscription.js": "/chunks/user-subscription.js?id=370b3df08b2ee39bf6ac", - "/chunks/users.js": "/chunks/users.js?id=562f40bdfc51d8c5d4dd", + "/chunks/users.js": "/chunks/users.js?id=8bd8edb68fbc5c7808c1", "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~24b428d3.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~24b428d3.js?id=ee89932f7ee76e74483e", "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~b505e62a.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~b505e62a.js?id=8163e0eab55c50f8afb8", "/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~40ccbae3.js": "/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~40ccbae3.js?id=37ce1e1ab9968c100712", "/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js": "/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js?id=a0fa80db175709ba340a", - "/js/main.6b018378a9544d5d4804.hot-update.js": "/js/main.6b018378a9544d5d4804.hot-update.js", - "/js/main.3336859d5f1fe2fbd58e.hot-update.js": "/js/main.3336859d5f1fe2fbd58e.hot-update.js" + "/chunks/plan-create.55127b953178adc257a1.hot-update.js": "/chunks/plan-create.55127b953178adc257a1.hot-update.js", + "/chunks/upgrade-billing~chunks/upgrade-plan.55127b953178adc257a1.hot-update.js": "/chunks/upgrade-billing~chunks/upgrade-plan.55127b953178adc257a1.hot-update.js", + "/chunks/user-create.55127b953178adc257a1.hot-update.js": "/chunks/user-create.55127b953178adc257a1.hot-update.js", + "/chunks/user-storage.55127b953178adc257a1.hot-update.js": "/chunks/user-storage.55127b953178adc257a1.hot-update.js", + "/chunks/users.55127b953178adc257a1.hot-update.js": "/chunks/users.55127b953178adc257a1.hot-update.js" } diff --git a/resources/js/components/Others/PlanPricingTables.vue b/resources/js/components/Others/PlanPricingTables.vue index e064ed0a..7f60dc08 100644 --- a/resources/js/components/Others/PlanPricingTables.vue +++ b/resources/js/components/Others/PlanPricingTables.vue @@ -63,7 +63,7 @@ axios.get('/api/pricing') .then(response => { this.plans = response.data.filter(plan => { - return plan.data.attributes.capacity > this.user.data.attributes.storage_capacity + return plan.data.attributes.capacity > this.user.data.attributes.max_storage_amount }) this.$emit('load', false) }) diff --git a/resources/js/views/Admin/Plans/PlanCreate.vue b/resources/js/views/Admin/Plans/PlanCreate.vue index 5fd2e981..891e5ed2 100644 --- a/resources/js/views/Admin/Plans/PlanCreate.vue +++ b/resources/js/views/Admin/Plans/PlanCreate.vue @@ -151,7 +151,7 @@ // Validation errors if (error.response.status == 422) { - if (error.response.data.errors['storage_capacity']) { + if (error.response.data.errors['max_storage_amount']) { this.$refs.createPlan.setErrors({ 'storage capacity': this.$t('errors.capacity_digit') }); diff --git a/resources/js/views/Admin/Users.vue b/resources/js/views/Admin/Users.vue index 7f143f28..81bce8b6 100644 --- a/resources/js/views/Admin/Users.vue +++ b/resources/js/views/Admin/Users.vue @@ -159,8 +159,8 @@ sortable: true }, { - label: this.$t('admin_page_user.table.storage_capacity'), - field: 'settings.storage_capacity', + label: this.$t('admin_page_user.table.max_storage_amount'), + field: 'settings.max_storage_amount', sortable: true, hidden: ! this.config.storageLimit, }, diff --git a/resources/js/views/Admin/Users/UserCreate.vue b/resources/js/views/Admin/Users/UserCreate.vue index 124726fb..83a39844 100644 --- a/resources/js/views/Admin/Users/UserCreate.vue +++ b/resources/js/views/Admin/Users/UserCreate.vue @@ -72,7 +72,7 @@
- + {{ errors[0] }}
@@ -130,7 +130,7 @@ email: '', password: '', password_confirmation: '', - storage_capacity: 5, + max_storage_amount: 5, }, } }, @@ -153,7 +153,7 @@ formData.append('role', this.user.role) formData.append('email', this.user.email) formData.append('password', this.user.password) - formData.append('storage_capacity', this.user.storage_capacity) + formData.append('max_storage_amount', this.user.max_storage_amount) formData.append('password_confirmation', this.user.password_confirmation) // Append avatar if exist @@ -203,7 +203,7 @@ } // Password validation error - if (error.response.data.errors['storage_capacity']) { + if (error.response.data.errors['max_storage_amount']) { this.$refs.createUser.setErrors({ 'storage capacity': this.$t('errors.capacity_digit') diff --git a/resources/js/views/Admin/Users/UserTabs/UserStorage.vue b/resources/js/views/Admin/Users/UserTabs/UserStorage.vue index d8e4229f..39a576c4 100644 --- a/resources/js/views/Admin/Users/UserTabs/UserStorage.vue +++ b/resources/js/views/Admin/Users/UserTabs/UserStorage.vue @@ -99,7 +99,7 @@ axios .post(this.$store.getters.api + '/admin/users/' + this.$route.params.id + '/capacity', { attributes: { - storage_capacity: this.capacity + max_storage_amount: this.capacity }, _method: 'patch' }) @@ -124,7 +124,7 @@ if (error.response.status == 422) { // Password validation error - if (error.response.data.errors['attributes.storage_capacity']) { + if (error.response.data.errors['attributes.max_storage_amount']) { this.$refs.changeStorageCapacity.setErrors({ 'Capacity': this.$t('errors.capacity_digit') diff --git a/src/App/Console/Commands/SetupDevEnvironment.php b/src/App/Console/Commands/SetupDevEnvironment.php index 2b86d6b3..ceca2d39 100644 --- a/src/App/Console/Commands/SetupDevEnvironment.php +++ b/src/App/Console/Commands/SetupDevEnvironment.php @@ -103,16 +103,16 @@ class SetupDevEnvironment extends Command $user ->settings() ->create([ - 'avatar' => $avatar_name, - 'storage_capacity' => 5, - 'name' => 'Jane Doe', - 'address' => $this->faker->address, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'postal_code' => $this->faker->postcode, - 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), - 'phone_number' => $this->faker->phoneNumber, - 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), + 'avatar' => $avatar_name, + 'max_storage_amount' => 5, + 'name' => 'Jane Doe', + 'address' => $this->faker->address, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'postal_code' => $this->faker->postcode, + 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), + 'phone_number' => $this->faker->phoneNumber, + 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), ]); // Show user credentials @@ -162,16 +162,16 @@ class SetupDevEnvironment extends Command $newbie ->settings() ->create([ - 'avatar' => $avatar_name, - 'storage_capacity' => 5, - 'name' => $this->faker->name, - 'address' => $this->faker->address, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'postal_code' => $this->faker->postcode, - 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), - 'phone_number' => $this->faker->phoneNumber, - 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), + 'avatar' => $avatar_name, + 'max_storage_amount' => 5, + 'name' => $this->faker->name, + 'address' => $this->faker->address, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'postal_code' => $this->faker->postcode, + 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), + 'phone_number' => $this->faker->phoneNumber, + 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), ]); $this->info("Generated user with email: $newbie->email and Password: vuefilemanager"); diff --git a/src/App/Console/Commands/SetupProdEnvironment.php b/src/App/Console/Commands/SetupProdEnvironment.php index 96909003..0270ef26 100644 --- a/src/App/Console/Commands/SetupProdEnvironment.php +++ b/src/App/Console/Commands/SetupProdEnvironment.php @@ -195,8 +195,8 @@ class SetupProdEnvironment extends Command $user ->settings() ->create([ - 'storage_capacity' => 5, - 'name' => 'Admin', + 'max_storage_amount' => 5, + 'name' => 'Admin', ]); // Show user credentials diff --git a/src/App/Providers/EventServiceProvider.php b/src/App/Providers/EventServiceProvider.php index a8fca9fe..ba1b6c9c 100644 --- a/src/App/Providers/EventServiceProvider.php +++ b/src/App/Providers/EventServiceProvider.php @@ -2,9 +2,9 @@ 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; -use Support\Listeners\SubscriptionEventSubscriber; class EventServiceProvider extends ServiceProvider { diff --git a/src/App/Users/Actions/CreateNewUserAction.php b/src/App/Users/Actions/CreateNewUserAction.php index e812d286..97013e8f 100644 --- a/src/App/Users/Actions/CreateNewUserAction.php +++ b/src/App/Users/Actions/CreateNewUserAction.php @@ -49,8 +49,8 @@ class CreateNewUserAction extends Controller $user ->settings() ->create([ - 'name' => $request->input('name'), - 'storage_capacity' => $settings['storage_default'], + 'name' => $request->input('name'), + 'max_storage_amount' => $settings['storage_default'], ]); UserSettings::reguard(); diff --git a/src/App/Users/Models/User.php b/src/App/Users/Models/User.php index efc66c0b..54976ecb 100644 --- a/src/App/Users/Models/User.php +++ b/src/App/Users/Models/User.php @@ -74,7 +74,7 @@ class User extends Authenticatable implements MustVerifyEmail 'name', 'role', 'created_at', - 'storage_capacity', + 'max_storage_amount', ]; public $incrementing = false; @@ -101,10 +101,10 @@ class User extends Authenticatable implements MustVerifyEmail } return [ - 'used' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity), - 'used_formatted' => get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity) . '%', - 'capacity' => $this->settings->storage_capacity, - 'capacity_formatted' => format_gigabytes($this->settings->storage_capacity), + 'used' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->max_storage_amount), + 'used_formatted' => get_storage_fill_percentage($this->usedCapacity, $this->settings->max_storage_amount) . '%', + 'capacity' => $this->settings->max_storage_amount, + 'capacity_formatted' => format_gigabytes($this->settings->max_storage_amount), ]; } diff --git a/src/App/Users/Models/UserSettings.php b/src/App/Users/Models/UserSettings.php index 3988ed4f..59e240de 100644 --- a/src/App/Users/Models/UserSettings.php +++ b/src/App/Users/Models/UserSettings.php @@ -10,7 +10,7 @@ class UserSettings extends Model protected $guarded = [ 'id', - 'storage_capacity', + 'max_storage_amount', ]; /** diff --git a/src/App/Users/Resources/UserResource.php b/src/App/Users/Resources/UserResource.php index b84cb280..150dedcb 100644 --- a/src/App/Users/Resources/UserResource.php +++ b/src/App/Users/Resources/UserResource.php @@ -20,15 +20,15 @@ class UserResource extends JsonResource 'id' => $this->id, 'type' => 'user', 'attributes' => [ - 'storage_capacity' => $this->settings->storage_capacity, - 'email' => is_demo() ? obfuscate_email($this->email) : $this->email, - 'role' => $this->role, - 'two_factor_authentication' => $this->two_factor_secret ? true : false, - 'folders' => $this->folder_tree, - 'storage' => $this->storage, - 'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'), - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'max_storage_amount' => $this->settings->max_storage_amount, + 'email' => is_demo() ? obfuscate_email($this->email) : $this->email, + 'role' => $this->role, + 'two_factor_authentication' => $this->two_factor_secret ? true : false, + 'folders' => $this->folder_tree, + 'storage' => $this->storage, + 'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ], 'relationships' => [ 'settings' => [ diff --git a/src/App/Users/Resources/UserStorageResource.php b/src/App/Users/Resources/UserStorageResource.php index 8d892335..f818627d 100644 --- a/src/App/Users/Resources/UserStorageResource.php +++ b/src/App/Users/Resources/UserStorageResource.php @@ -47,29 +47,29 @@ class UserStorageResource extends JsonResource 'type' => 'storage', 'attributes' => [ 'used' => Metric::bytes($this->usedCapacity)->format(), - 'capacity' => format_gigabytes($this->settings->storage_capacity), - 'percentage' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity), + 'capacity' => format_gigabytes($this->settings->max_storage_amount), + 'percentage' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->max_storage_amount), ], 'meta' => [ 'images' => [ 'used' => Metric::bytes($images)->format(), - 'percentage' => (float) get_storage_fill_percentage($images, $this->settings->storage_capacity), + 'percentage' => (float) get_storage_fill_percentage($images, $this->settings->max_storage_amount), ], 'audios' => [ 'used' => Metric::bytes($audios)->format(), - 'percentage' => (float) get_storage_fill_percentage($audios, $this->settings->storage_capacity), + 'percentage' => (float) get_storage_fill_percentage($audios, $this->settings->max_storage_amount), ], 'videos' => [ 'used' => Metric::bytes($videos)->format(), - 'percentage' => (float) get_storage_fill_percentage($videos, $this->settings->storage_capacity), + 'percentage' => (float) get_storage_fill_percentage($videos, $this->settings->max_storage_amount), ], 'documents' => [ 'used' => Metric::bytes($documents)->format(), - 'percentage' => (float) get_storage_fill_percentage($documents, $this->settings->storage_capacity), + 'percentage' => (float) get_storage_fill_percentage($documents, $this->settings->max_storage_amount), ], 'others' => [ 'used' => Metric::bytes($others)->format(), - 'percentage' => (float) get_storage_fill_percentage($others, $this->settings->storage_capacity), + 'percentage' => (float) get_storage_fill_percentage($others, $this->settings->max_storage_amount), ], ], ], diff --git a/src/Domain/Admin/Controllers/Dashboard/GetWidgetsValuesController.php b/src/Domain/Admin/Controllers/Dashboard/GetWidgetsValuesController.php index c6b45ff8..2d46240c 100644 --- a/src/Domain/Admin/Controllers/Dashboard/GetWidgetsValuesController.php +++ b/src/Domain/Admin/Controllers/Dashboard/GetWidgetsValuesController.php @@ -3,7 +3,6 @@ namespace Domain\Admin\Controllers\Dashboard; use ByteUnits\Metric; use App\Users\Models\User; -use Laravel\Cashier\Subscription; use App\Http\Controllers\Controller; class GetWidgetsValuesController extends Controller diff --git a/src/Domain/Admin/Controllers/Users/UserController.php b/src/Domain/Admin/Controllers/Users/UserController.php index 879cecdd..8f370d7d 100644 --- a/src/Domain/Admin/Controllers/Users/UserController.php +++ b/src/Domain/Admin/Controllers/Users/UserController.php @@ -48,9 +48,9 @@ class UserController extends Controller $user ->settings() ->create([ - 'storage_capacity' => $request->input('storage_capacity'), - 'avatar' => store_avatar($request, 'avatar'), - 'name' => $request->input('name'), + 'max_storage_amount' => $request->input('max_storage_amount'), + 'avatar' => store_avatar($request, 'avatar'), + 'name' => $request->input('name'), ]); UserSettings::reguard(); diff --git a/src/Domain/Admin/Requests/ChangeStorageCapacityRequest.php b/src/Domain/Admin/Requests/ChangeStorageCapacityRequest.php index 4c10ed52..f9f0141c 100644 --- a/src/Domain/Admin/Requests/ChangeStorageCapacityRequest.php +++ b/src/Domain/Admin/Requests/ChangeStorageCapacityRequest.php @@ -23,8 +23,8 @@ class ChangeStorageCapacityRequest extends FormRequest public function rules() { return [ - 'attributes' => 'required|array', - 'attributes.storage_capacity' => 'required|digits_between:1,9', + 'attributes' => 'required|array', + 'attributes.max_storage_amount' => 'required|digits_between:1,9', ]; } } diff --git a/src/Domain/Admin/Requests/CreateUserByAdmin.php b/src/Domain/Admin/Requests/CreateUserByAdmin.php index 1a8f7e17..cec5464b 100644 --- a/src/Domain/Admin/Requests/CreateUserByAdmin.php +++ b/src/Domain/Admin/Requests/CreateUserByAdmin.php @@ -23,12 +23,12 @@ class CreateUserByAdmin extends FormRequest public function rules() { return [ - 'email' => 'required|string|email|max:255|unique:users', - 'password' => 'required|string|min:6|confirmed', - 'name' => 'required|string|max:255', - 'storage_capacity' => 'required|digits_between:1,9', - 'role' => 'required|string', - 'avatar' => 'sometimes|file', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6|confirmed', + 'name' => 'required|string|max:255', + 'max_storage_amount' => 'required|digits_between:1,9', + 'role' => 'required|string', + 'avatar' => 'sometimes|file', ]; } } diff --git a/src/Domain/SetupWizard/Controllers/CreateAdminAccountController.php b/src/Domain/SetupWizard/Controllers/CreateAdminAccountController.php index 2da6fe48..57f0b2ea 100644 --- a/src/Domain/SetupWizard/Controllers/CreateAdminAccountController.php +++ b/src/Domain/SetupWizard/Controllers/CreateAdminAccountController.php @@ -48,9 +48,9 @@ class CreateAdminAccountController extends Controller $user ->settings() ->create([ - 'storage_capacity' => get_settings('storage_default') ?? 5, - 'avatar' => store_avatar($request, 'avatar'), - 'name' => $request->input('name'), + 'max_storage_amount' => get_settings('storage_default') ?? 5, + 'avatar' => store_avatar($request, 'avatar'), + 'name' => $request->input('name'), ]); collect([ diff --git a/src/Domain/Teams/Actions/UpdateMembersAction.php b/src/Domain/Teams/Actions/UpdateMembersAction.php index a45a8159..e9c161f3 100644 --- a/src/Domain/Teams/Actions/UpdateMembersAction.php +++ b/src/Domain/Teams/Actions/UpdateMembersAction.php @@ -8,7 +8,8 @@ class UpdateMembersAction { public function __construct( public TransferContentOwnershipToTeamFolderOwnerAction $transferContentOwnership, - ) {} + ) { + } public function __invoke(Folder $folder, $members): void { diff --git a/src/Domain/Zip/Controllers/ZipController.php b/src/Domain/Zip/Controllers/ZipController.php index c1bf6db0..cd278137 100644 --- a/src/Domain/Zip/Controllers/ZipController.php +++ b/src/Domain/Zip/Controllers/ZipController.php @@ -1,12 +1,12 @@ plan->features()->pluck('value', 'key'); - - // Set user storage size + public function handleSubscriptionWasCreated($subscription) + { $subscription->user->settings->update([ - 'storage_capacity' => $features['max_storage_amount'] + 'max_storage_amount' => $subscription->feature('max_storage_amount'), + ]); + } + + public function handleSubscriptionWasUpdated($subscription) + { + $subscription->user->settings->update([ + 'max_storage_amount' => $subscription->feature('max_storage_amount'), + ]); + } + + public function handleSubscriptionWasExpired($subscription) + { + $subscription->user->settings->update([ + 'max_storage_amount' => get_settings('storage_default'), ]); } @@ -25,6 +36,8 @@ class SubscriptionEventSubscriber { return [ SubscriptionWasCreated::class => 'handleSubscriptionWasCreated', + SubscriptionWasExpired::class => 'handleSubscriptionWasExpired', + SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated', ]; } -} \ No newline at end of file +} diff --git a/src/Support/helpers.php b/src/Support/helpers.php index ec14688d..52bf9214 100644 --- a/src/Support/helpers.php +++ b/src/Support/helpers.php @@ -499,7 +499,7 @@ if (! function_exists('user_storage_percentage')) { $used = $user->usedCapacity + $additionals; } - return get_storage_fill_percentage($used, $user->settings->storage_capacity); + return get_storage_fill_percentage($used, $user->settings->max_storage_amount); } } diff --git a/tests/App/Users/SignFlowTest.php b/tests/App/Users/SignFlowTest.php index cc740b53..6fade47c 100644 --- a/tests/App/Users/SignFlowTest.php +++ b/tests/App/Users/SignFlowTest.php @@ -50,8 +50,8 @@ class SignFlowTest extends TestCase ]); $this->assertDatabaseHas('user_settings', [ - 'name' => 'John Doe', - 'storage_capacity' => 12, + 'name' => 'John Doe', + 'max_storage_amount' => 12, ]); Storage::disk('local') diff --git a/tests/App/Users/UserAccountTest.php b/tests/App/Users/UserAccountTest.php index 1040dce7..83864069 100644 --- a/tests/App/Users/UserAccountTest.php +++ b/tests/App/Users/UserAccountTest.php @@ -140,12 +140,12 @@ class UserAccountTest extends TestCase 'id' => (string) $user->id, 'type' => 'user', 'attributes' => [ - 'storage_capacity' => '5', - 'email' => $user->email, - 'role' => $user->role, - 'two_factor_authentication' => false, - 'folders' => [], - 'storage' => [ + 'max_storage_amount' => '5', + 'email' => $user->email, + 'role' => $user->role, + 'two_factor_authentication' => false, + 'folders' => [], + 'storage' => [ 'used' => 0, 'used_formatted' => '0.00%', 'capacity' => '5', diff --git a/tests/Domain/Admin/AdminTest.php b/tests/Domain/Admin/AdminTest.php index 96a8e8da..c42187be 100644 --- a/tests/Domain/Admin/AdminTest.php +++ b/tests/Domain/Admin/AdminTest.php @@ -170,13 +170,13 @@ class AdminTest extends TestCase ->actingAs($admin) ->patchJson("/api/admin/users/$user->id/capacity", [ 'attributes' => [ - 'storage_capacity' => 10, + 'max_storage_amount' => 10, ], ])->assertStatus(200); $this->assertDatabaseHas('user_settings', [ - 'user_id' => $user->id, - 'storage_capacity' => 10, + 'user_id' => $user->id, + 'max_storage_amount' => 10, ]); } @@ -216,13 +216,13 @@ class AdminTest extends TestCase $this ->actingAs($admin) ->postJson('/api/admin/users', [ - 'name' => 'John Doe', - 'role' => 'user', - 'email' => 'john@doe.com', - 'password' => 'VerySecretPassword', - 'storage_capacity' => 15, - 'password_confirmation' => 'VerySecretPassword', - 'avatar' => $avatar, + 'name' => 'John Doe', + 'role' => 'user', + 'email' => 'john@doe.com', + 'password' => 'VerySecretPassword', + 'max_storage_amount' => 15, + 'password_confirmation' => 'VerySecretPassword', + 'avatar' => $avatar, ])->assertStatus(201); $this->assertDatabaseHas('users', [ diff --git a/tests/Domain/Admin/DashboardTest.php b/tests/Domain/Admin/DashboardTest.php index 2b4982ec..99d4b4d9 100644 --- a/tests/Domain/Admin/DashboardTest.php +++ b/tests/Domain/Admin/DashboardTest.php @@ -1,7 +1,6 @@ create(); $user->settings()->update([ - 'storage_capacity' => 1, + 'max_storage_amount' => 1, ]); File::factory(File::class)