event implementation

This commit is contained in:
Čarodej
2021-11-19 17:08:49 +01:00
parent 496a6ea5a7
commit 7c5cb79677
32 changed files with 135 additions and 121 deletions
+1 -2
View File
@@ -98,7 +98,6 @@
"post-create-project-cmd": [ "post-create-project-cmd": [
"@php artisan key:generate --ansi" "@php artisan key:generate --ansi"
], ],
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
"psalm": "vendor/bin/psalm"
} }
} }
Generated
+6 -6
View File
@@ -5279,16 +5279,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.8", "version": "9.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e" "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -5344,7 +5344,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "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": [ "funding": [
{ {
@@ -5352,7 +5352,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-10-30T08:01:38+00:00" "time": "2021-11-19T15:21:02+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
+1 -1
View File
@@ -48,7 +48,7 @@ class UserFactory extends Factory
$user $user
->settings() ->settings()
->create([ ->create([
'storage_capacity' => $this->faker->randomNumber(1), 'max_storage_amount' => $this->faker->randomNumber(1),
'name' => $this->faker->name, 'name' => $this->faker->name,
'address' => $this->faker->address, 'address' => $this->faker->address,
'state' => $this->faker->state, 'state' => $this->faker->state,
@@ -15,7 +15,7 @@ class CreateUserSettingsTable extends Migration
{ {
Schema::create('user_settings', function (Blueprint $table) { Schema::create('user_settings', function (Blueprint $table) {
$table->uuid('user_id')->index(); $table->uuid('user_id')->index();
$table->integer('storage_capacity')->default(5); $table->integer('max_storage_amount')->default(5);
$table->string('avatar')->nullable(); $table->string('avatar')->nullable();
$table->string('color')->nullable(); $table->string('color')->nullable();
$table->text('name')->nullable(); $table->text('name')->nullable();
+10 -7
View File
@@ -53,7 +53,7 @@
"/chunks/page-edit.js": "/chunks/page-edit.js?id=1963acc189f3f92441a6", "/chunks/page-edit.js": "/chunks/page-edit.js?id=1963acc189f3f92441a6",
"/chunks/pages.js": "/chunks/pages.js?id=f5c86b24fcbe15b15d1d", "/chunks/pages.js": "/chunks/pages.js?id=f5c86b24fcbe15b15d1d",
"/chunks/plan.js": "/chunks/plan.js?id=052940a7395f559b7c60", "/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-delete.js": "/chunks/plan-delete.js?id=96f48131997a0092be4b",
"/chunks/plan-settings.js": "/chunks/plan-settings.js?id=2f403063c6a896f09e17", "/chunks/plan-settings.js": "/chunks/plan-settings.js?id=2f403063c6a896f09e17",
"/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=99854b8b4518fbebc79f", "/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/team-folders.js": "/chunks/team-folders.js?id=0e69f4432e968cc512f9",
"/chunks/trash.js": "/chunks/trash.js?id=5fe84aadd8729e68849e", "/chunks/trash.js": "/chunks/trash.js?id=5fe84aadd8729e68849e",
"/chunks/upgrade-billing.js": "/chunks/upgrade-billing.js?id=2bffa85e82a5cda1dcd2", "/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/upgrade-plan.js": "/chunks/upgrade-plan.js?id=460e6f80d824b5a93adf",
"/chunks/user.js": "/chunks/user.js?id=fe26116ebc97069cf7f9", "/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-delete.js": "/chunks/user-delete.js?id=36e7149e777f1ecd71e9",
"/chunks/user-detail.js": "/chunks/user-detail.js?id=6218f429f4040d0524ac", "/chunks/user-detail.js": "/chunks/user-detail.js?id=6218f429f4040d0524ac",
"/chunks/user-invoices.js": "/chunks/user-invoices.js?id=386719adbd52708773ba", "/chunks/user-invoices.js": "/chunks/user-invoices.js?id=386719adbd52708773ba",
"/chunks/user-password.js": "/chunks/user-password.js?id=22725c9c88b862276b34", "/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/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~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/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/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", "/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", "/chunks/plan-create.55127b953178adc257a1.hot-update.js": "/chunks/plan-create.55127b953178adc257a1.hot-update.js",
"/js/main.3336859d5f1fe2fbd58e.hot-update.js": "/js/main.3336859d5f1fe2fbd58e.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"
} }
@@ -63,7 +63,7 @@
axios.get('/api/pricing') axios.get('/api/pricing')
.then(response => { .then(response => {
this.plans = response.data.filter(plan => { 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) this.$emit('load', false)
}) })
@@ -151,7 +151,7 @@
// Validation errors // Validation errors
if (error.response.status == 422) { if (error.response.status == 422) {
if (error.response.data.errors['storage_capacity']) { if (error.response.data.errors['max_storage_amount']) {
this.$refs.createPlan.setErrors({ this.$refs.createPlan.setErrors({
'storage capacity': this.$t('errors.capacity_digit') 'storage capacity': this.$t('errors.capacity_digit')
}); });
+2 -2
View File
@@ -159,8 +159,8 @@
sortable: true sortable: true
}, },
{ {
label: this.$t('admin_page_user.table.storage_capacity'), label: this.$t('admin_page_user.table.max_storage_amount'),
field: 'settings.storage_capacity', field: 'settings.max_storage_amount',
sortable: true, sortable: true,
hidden: ! this.config.storageLimit, hidden: ! this.config.storageLimit,
}, },
@@ -72,7 +72,7 @@
<div class="block-wrapper"> <div class="block-wrapper">
<label>{{ $t('admin_page_user.label_change_capacity') }}</label> <label>{{ $t('admin_page_user.label_change_capacity') }}</label>
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="storage capacity" rules="required" v-slot="{ errors }"> <ValidationProvider tag="div" mode="passive" class="input-wrapper" name="storage capacity" rules="required" v-slot="{ errors }">
<input v-model="user.storage_capacity" min="1" max="999999999" :placeholder="$t('admin_page_user.label_change_capacity')" type="number" class="focus-border-theme" :class="{'is-error': errors[0]}"/> <input v-model="user.max_storage_amount" min="1" max="999999999" :placeholder="$t('admin_page_user.label_change_capacity')" type="number" class="focus-border-theme" :class="{'is-error': errors[0]}"/>
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span> <span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
</ValidationProvider> </ValidationProvider>
</div> </div>
@@ -130,7 +130,7 @@
email: '', email: '',
password: '', password: '',
password_confirmation: '', password_confirmation: '',
storage_capacity: 5, max_storage_amount: 5,
}, },
} }
}, },
@@ -153,7 +153,7 @@
formData.append('role', this.user.role) formData.append('role', this.user.role)
formData.append('email', this.user.email) formData.append('email', this.user.email)
formData.append('password', this.user.password) 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) formData.append('password_confirmation', this.user.password_confirmation)
// Append avatar if exist // Append avatar if exist
@@ -203,7 +203,7 @@
} }
// Password validation error // Password validation error
if (error.response.data.errors['storage_capacity']) { if (error.response.data.errors['max_storage_amount']) {
this.$refs.createUser.setErrors({ this.$refs.createUser.setErrors({
'storage capacity': this.$t('errors.capacity_digit') 'storage capacity': this.$t('errors.capacity_digit')
@@ -99,7 +99,7 @@
axios axios
.post(this.$store.getters.api + '/admin/users/' + this.$route.params.id + '/capacity', { .post(this.$store.getters.api + '/admin/users/' + this.$route.params.id + '/capacity', {
attributes: { attributes: {
storage_capacity: this.capacity max_storage_amount: this.capacity
}, },
_method: 'patch' _method: 'patch'
}) })
@@ -124,7 +124,7 @@
if (error.response.status == 422) { if (error.response.status == 422) {
// Password validation error // Password validation error
if (error.response.data.errors['attributes.storage_capacity']) { if (error.response.data.errors['attributes.max_storage_amount']) {
this.$refs.changeStorageCapacity.setErrors({ this.$refs.changeStorageCapacity.setErrors({
'Capacity': this.$t('errors.capacity_digit') 'Capacity': this.$t('errors.capacity_digit')
@@ -103,16 +103,16 @@ class SetupDevEnvironment extends Command
$user $user
->settings() ->settings()
->create([ ->create([
'avatar' => $avatar_name, 'avatar' => $avatar_name,
'storage_capacity' => 5, 'max_storage_amount' => 5,
'name' => 'Jane Doe', 'name' => 'Jane Doe',
'address' => $this->faker->address, 'address' => $this->faker->address,
'state' => $this->faker->state, 'state' => $this->faker->state,
'city' => $this->faker->city, 'city' => $this->faker->city,
'postal_code' => $this->faker->postcode, 'postal_code' => $this->faker->postcode,
'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']),
'phone_number' => $this->faker->phoneNumber, 'phone_number' => $this->faker->phoneNumber,
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
]); ]);
// Show user credentials // Show user credentials
@@ -162,16 +162,16 @@ class SetupDevEnvironment extends Command
$newbie $newbie
->settings() ->settings()
->create([ ->create([
'avatar' => $avatar_name, 'avatar' => $avatar_name,
'storage_capacity' => 5, 'max_storage_amount' => 5,
'name' => $this->faker->name, 'name' => $this->faker->name,
'address' => $this->faker->address, 'address' => $this->faker->address,
'state' => $this->faker->state, 'state' => $this->faker->state,
'city' => $this->faker->city, 'city' => $this->faker->city,
'postal_code' => $this->faker->postcode, 'postal_code' => $this->faker->postcode,
'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']),
'phone_number' => $this->faker->phoneNumber, 'phone_number' => $this->faker->phoneNumber,
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
]); ]);
$this->info("Generated user with email: $newbie->email and Password: vuefilemanager"); $this->info("Generated user with email: $newbie->email and Password: vuefilemanager");
@@ -195,8 +195,8 @@ class SetupProdEnvironment extends Command
$user $user
->settings() ->settings()
->create([ ->create([
'storage_capacity' => 5, 'max_storage_amount' => 5,
'name' => 'Admin', 'name' => 'Admin',
]); ]);
// Show user credentials // Show user credentials
+1 -1
View File
@@ -2,9 +2,9 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Support\Listeners\SubscriptionEventSubscriber;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Support\Listeners\SubscriptionEventSubscriber;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {
@@ -49,8 +49,8 @@ class CreateNewUserAction extends Controller
$user $user
->settings() ->settings()
->create([ ->create([
'name' => $request->input('name'), 'name' => $request->input('name'),
'storage_capacity' => $settings['storage_default'], 'max_storage_amount' => $settings['storage_default'],
]); ]);
UserSettings::reguard(); UserSettings::reguard();
+5 -5
View File
@@ -74,7 +74,7 @@ class User extends Authenticatable implements MustVerifyEmail
'name', 'name',
'role', 'role',
'created_at', 'created_at',
'storage_capacity', 'max_storage_amount',
]; ];
public $incrementing = false; public $incrementing = false;
@@ -101,10 +101,10 @@ class User extends Authenticatable implements MustVerifyEmail
} }
return [ return [
'used' => (float) get_storage_fill_percentage($this->usedCapacity, $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->storage_capacity) . '%', 'used_formatted' => get_storage_fill_percentage($this->usedCapacity, $this->settings->max_storage_amount) . '%',
'capacity' => $this->settings->storage_capacity, 'capacity' => $this->settings->max_storage_amount,
'capacity_formatted' => format_gigabytes($this->settings->storage_capacity), 'capacity_formatted' => format_gigabytes($this->settings->max_storage_amount),
]; ];
} }
+1 -1
View File
@@ -10,7 +10,7 @@ class UserSettings extends Model
protected $guarded = [ protected $guarded = [
'id', 'id',
'storage_capacity', 'max_storage_amount',
]; ];
/** /**
+9 -9
View File
@@ -20,15 +20,15 @@ class UserResource extends JsonResource
'id' => $this->id, 'id' => $this->id,
'type' => 'user', 'type' => 'user',
'attributes' => [ 'attributes' => [
'storage_capacity' => $this->settings->storage_capacity, 'max_storage_amount' => $this->settings->max_storage_amount,
'email' => is_demo() ? obfuscate_email($this->email) : $this->email, 'email' => is_demo() ? obfuscate_email($this->email) : $this->email,
'role' => $this->role, 'role' => $this->role,
'two_factor_authentication' => $this->two_factor_secret ? true : false, 'two_factor_authentication' => $this->two_factor_secret ? true : false,
'folders' => $this->folder_tree, 'folders' => $this->folder_tree,
'storage' => $this->storage, 'storage' => $this->storage,
'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'), 'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'),
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'updated_at' => $this->updated_at, 'updated_at' => $this->updated_at,
], ],
'relationships' => [ 'relationships' => [
'settings' => [ 'settings' => [
@@ -47,29 +47,29 @@ class UserStorageResource extends JsonResource
'type' => 'storage', 'type' => 'storage',
'attributes' => [ 'attributes' => [
'used' => Metric::bytes($this->usedCapacity)->format(), 'used' => Metric::bytes($this->usedCapacity)->format(),
'capacity' => format_gigabytes($this->settings->storage_capacity), 'capacity' => format_gigabytes($this->settings->max_storage_amount),
'percentage' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity), 'percentage' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->max_storage_amount),
], ],
'meta' => [ 'meta' => [
'images' => [ 'images' => [
'used' => Metric::bytes($images)->format(), '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' => [ 'audios' => [
'used' => Metric::bytes($audios)->format(), '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' => [ 'videos' => [
'used' => Metric::bytes($videos)->format(), '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' => [ 'documents' => [
'used' => Metric::bytes($documents)->format(), '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' => [ 'others' => [
'used' => Metric::bytes($others)->format(), '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),
], ],
], ],
], ],
@@ -3,7 +3,6 @@ namespace Domain\Admin\Controllers\Dashboard;
use ByteUnits\Metric; use ByteUnits\Metric;
use App\Users\Models\User; use App\Users\Models\User;
use Laravel\Cashier\Subscription;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
class GetWidgetsValuesController extends Controller class GetWidgetsValuesController extends Controller
@@ -48,9 +48,9 @@ class UserController extends Controller
$user $user
->settings() ->settings()
->create([ ->create([
'storage_capacity' => $request->input('storage_capacity'), 'max_storage_amount' => $request->input('max_storage_amount'),
'avatar' => store_avatar($request, 'avatar'), 'avatar' => store_avatar($request, 'avatar'),
'name' => $request->input('name'), 'name' => $request->input('name'),
]); ]);
UserSettings::reguard(); UserSettings::reguard();
@@ -23,8 +23,8 @@ class ChangeStorageCapacityRequest extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'attributes' => 'required|array', 'attributes' => 'required|array',
'attributes.storage_capacity' => 'required|digits_between:1,9', 'attributes.max_storage_amount' => 'required|digits_between:1,9',
]; ];
} }
} }
@@ -23,12 +23,12 @@ class CreateUserByAdmin extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'email' => 'required|string|email|max:255|unique:users', 'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed', 'password' => 'required|string|min:6|confirmed',
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'storage_capacity' => 'required|digits_between:1,9', 'max_storage_amount' => 'required|digits_between:1,9',
'role' => 'required|string', 'role' => 'required|string',
'avatar' => 'sometimes|file', 'avatar' => 'sometimes|file',
]; ];
} }
} }
@@ -48,9 +48,9 @@ class CreateAdminAccountController extends Controller
$user $user
->settings() ->settings()
->create([ ->create([
'storage_capacity' => get_settings('storage_default') ?? 5, 'max_storage_amount' => get_settings('storage_default') ?? 5,
'avatar' => store_avatar($request, 'avatar'), 'avatar' => store_avatar($request, 'avatar'),
'name' => $request->input('name'), 'name' => $request->input('name'),
]); ]);
collect([ collect([
@@ -8,7 +8,8 @@ class UpdateMembersAction
{ {
public function __construct( public function __construct(
public TransferContentOwnershipToTeamFolderOwnerAction $transferContentOwnership, public TransferContentOwnershipToTeamFolderOwnerAction $transferContentOwnership,
) {} ) {
}
public function __invoke(Folder $folder, $members): void public function __invoke(Folder $folder, $members): void
{ {
+1 -1
View File
@@ -1,12 +1,12 @@
<?php <?php
namespace Domain\Zip\Controllers; namespace Domain\Zip\Controllers;
use ZipStream\ZipStream;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Domain\Zip\Actions\ZipAction; use Domain\Zip\Actions\ZipAction;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Domain\Traffic\Actions\RecordDownloadAction; use Domain\Traffic\Actions\RecordDownloadAction;
use Domain\Zip\Actions\GetItemsListFromUrlParamAction; use Domain\Zip\Actions\GetItemsListFromUrlParamAction;
use ZipStream\ZipStream;
class ZipController extends Controller class ZipController extends Controller
{ {
@@ -1,20 +1,31 @@
<?php <?php
namespace Support\Listeners; namespace Support\Listeners;
use Illuminate\Events\Dispatcher; use Illuminate\Events\Dispatcher;
use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated; use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated;
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
use VueFileManager\Subscription\Support\Events\SubscriptionWasUpdated;
class SubscriptionEventSubscriber class SubscriptionEventSubscriber
{ {
public function handleSubscriptionWasCreated($subscription) { public function handleSubscriptionWasCreated($subscription)
{
// Get plan features
$features = $subscription->plan->features()->pluck('value', 'key');
// Set user storage size
$subscription->user->settings->update([ $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 [ return [
SubscriptionWasCreated::class => 'handleSubscriptionWasCreated', SubscriptionWasCreated::class => 'handleSubscriptionWasCreated',
SubscriptionWasExpired::class => 'handleSubscriptionWasExpired',
SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated',
]; ];
} }
} }
+1 -1
View File
@@ -499,7 +499,7 @@ if (! function_exists('user_storage_percentage')) {
$used = $user->usedCapacity + $additionals; $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);
} }
} }
+2 -2
View File
@@ -50,8 +50,8 @@ class SignFlowTest extends TestCase
]); ]);
$this->assertDatabaseHas('user_settings', [ $this->assertDatabaseHas('user_settings', [
'name' => 'John Doe', 'name' => 'John Doe',
'storage_capacity' => 12, 'max_storage_amount' => 12,
]); ]);
Storage::disk('local') Storage::disk('local')
+6 -6
View File
@@ -140,12 +140,12 @@ class UserAccountTest extends TestCase
'id' => (string) $user->id, 'id' => (string) $user->id,
'type' => 'user', 'type' => 'user',
'attributes' => [ 'attributes' => [
'storage_capacity' => '5', 'max_storage_amount' => '5',
'email' => $user->email, 'email' => $user->email,
'role' => $user->role, 'role' => $user->role,
'two_factor_authentication' => false, 'two_factor_authentication' => false,
'folders' => [], 'folders' => [],
'storage' => [ 'storage' => [
'used' => 0, 'used' => 0,
'used_formatted' => '0.00%', 'used_formatted' => '0.00%',
'capacity' => '5', 'capacity' => '5',
+10 -10
View File
@@ -170,13 +170,13 @@ class AdminTest extends TestCase
->actingAs($admin) ->actingAs($admin)
->patchJson("/api/admin/users/$user->id/capacity", [ ->patchJson("/api/admin/users/$user->id/capacity", [
'attributes' => [ 'attributes' => [
'storage_capacity' => 10, 'max_storage_amount' => 10,
], ],
])->assertStatus(200); ])->assertStatus(200);
$this->assertDatabaseHas('user_settings', [ $this->assertDatabaseHas('user_settings', [
'user_id' => $user->id, 'user_id' => $user->id,
'storage_capacity' => 10, 'max_storage_amount' => 10,
]); ]);
} }
@@ -216,13 +216,13 @@ class AdminTest extends TestCase
$this $this
->actingAs($admin) ->actingAs($admin)
->postJson('/api/admin/users', [ ->postJson('/api/admin/users', [
'name' => 'John Doe', 'name' => 'John Doe',
'role' => 'user', 'role' => 'user',
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'password' => 'VerySecretPassword', 'password' => 'VerySecretPassword',
'storage_capacity' => 15, 'max_storage_amount' => 15,
'password_confirmation' => 'VerySecretPassword', 'password_confirmation' => 'VerySecretPassword',
'avatar' => $avatar, 'avatar' => $avatar,
])->assertStatus(201); ])->assertStatus(201);
$this->assertDatabaseHas('users', [ $this->assertDatabaseHas('users', [
-1
View File
@@ -1,7 +1,6 @@
<?php <?php
namespace Tests\Domain\Admin; namespace Tests\Domain\Admin;
use DB;
use Tests\TestCase; use Tests\TestCase;
use App\Users\Models\User; use App\Users\Models\User;
use Laravel\Sanctum\Sanctum; use Laravel\Sanctum\Sanctum;
+1 -1
View File
@@ -112,7 +112,7 @@ class FileTest extends TestCase
->create(); ->create();
$user->settings()->update([ $user->settings()->update([
'storage_capacity' => 1, 'max_storage_amount' => 1,
]); ]);
File::factory(File::class) File::factory(File::class)