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
@@ -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
+1 -1
View File
@@ -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();
+5 -5
View File
@@ -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),
];
}
+1 -1
View File
@@ -10,7 +10,7 @@ class UserSettings extends Model
protected $guarded = [
'id',
'storage_capacity',
'max_storage_amount',
];
/**
+9 -9
View File
@@ -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),
],
],
],