mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
event implementation
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
12
composer.lock
generated
12
composer.lock
generated
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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')
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<div class="block-wrapper">
|
||||
<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 }">
|
||||
<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>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class UserSettings extends Model
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
'storage_capacity',
|
||||
'max_storage_amount',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -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' => [
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -8,7 +8,8 @@ class UpdateMembersAction
|
||||
{
|
||||
public function __construct(
|
||||
public TransferContentOwnershipToTeamFolderOwnerAction $transferContentOwnership,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(Folder $folder, $members): void
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Domain\Zip\Controllers;
|
||||
|
||||
use ZipStream\ZipStream;
|
||||
use Illuminate\Http\Request;
|
||||
use Domain\Zip\Actions\ZipAction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Domain\Zip\Actions\GetItemsListFromUrlParamAction;
|
||||
use ZipStream\ZipStream;
|
||||
|
||||
class ZipController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Support\Listeners;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasUpdated;
|
||||
|
||||
class SubscriptionEventSubscriber
|
||||
{
|
||||
public function handleSubscriptionWasCreated($subscription) {
|
||||
|
||||
// Get plan features
|
||||
$features = $subscription->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',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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', [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Tests\Domain\Admin;
|
||||
|
||||
use DB;
|
||||
use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
@@ -112,7 +112,7 @@ class FileTest extends TestCase
|
||||
->create();
|
||||
|
||||
$user->settings()->update([
|
||||
'storage_capacity' => 1,
|
||||
'max_storage_amount' => 1,
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
|
||||
Reference in New Issue
Block a user