+
+
+
+
+ {{ $t('Alert will be triggered after you reach the value above.') }}
+
+
+
+
+
-
-
+
+ {{ $t('Update Alert') }}
+
+
+
+
+
+
+
+
+
+
+
+
{{ $t('Set Alert') }}
@@ -149,10 +181,15 @@
diff --git a/src/App/Console/Commands/SetupDevEnvironment.php b/src/App/Console/Commands/SetupDevEnvironment.php
index 0462fbbe..9440281c 100644
--- a/src/App/Console/Commands/SetupDevEnvironment.php
+++ b/src/App/Console/Commands/SetupDevEnvironment.php
@@ -1093,14 +1093,14 @@ class SetupDevEnvironment extends Command
$user
->each(
fn ($user) => DB::table('traffic')
- ->insert([
- 'id' => Str::uuid(),
- 'user_id' => $user->id,
- 'upload' => random_int(1111111, 9999999),
- 'download' => random_int(11111111, 99999999),
- 'created_at' => now()->subDays($day),
- 'updated_at' => now()->subDays($day),
- ])
+ ->insert([
+ 'id' => Str::uuid(),
+ 'user_id' => $user->id,
+ 'upload' => random_int(1111111, 9999999),
+ 'download' => random_int(11111111, 99999999),
+ 'created_at' => now()->subDays($day),
+ 'updated_at' => now()->subDays($day),
+ ])
);
}
}
diff --git a/src/App/Console/Kernel.php b/src/App/Console/Kernel.php
index 9428efc5..9ec888b1 100644
--- a/src/App/Console/Kernel.php
+++ b/src/App/Console/Kernel.php
@@ -4,11 +4,11 @@ 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\Scheduler\Actions\DeleteFailedFilesAction;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
-use Support\Scheduler\Actions\ReportUsageAction;
class Kernel extends ConsoleKernel
{
diff --git a/src/App/Users/Actions/FormatUsageEstimatesAction.php b/src/App/Users/Actions/FormatUsageEstimatesAction.php
index 73f01684..176cd6b5 100644
--- a/src/App/Users/Actions/FormatUsageEstimatesAction.php
+++ b/src/App/Users/Actions/FormatUsageEstimatesAction.php
@@ -1,5 +1,4 @@
map(function ($estimate) use ($currency) {
-
// Format usage
$usage = match ($estimate['feature']) {
'bandwidth' => Metric::megabytes($estimate['usage'])->format(),
- 'storage' => Metric::megabytes($estimate['usage'])->format(),
+ 'storage' => Metric::megabytes($estimate['usage'])->format(),
};
// Normalize units
@@ -28,4 +26,4 @@ class FormatUsageEstimatesAction
];
});
}
-}
\ No newline at end of file
+}
diff --git a/src/App/Users/Resources/UserResource.php b/src/App/Users/Resources/UserResource.php
index 4ee8b077..2e4e6f50 100644
--- a/src/App/Users/Resources/UserResource.php
+++ b/src/App/Users/Resources/UserResource.php
@@ -1,13 +1,13 @@
[
'settings' => new SettingsResource($this->settings),
'favourites' => new FolderCollection($this->favouriteFolders),
- $this->mergeWhen($this->hasSubscription(), fn() => [
+ $this->mergeWhen($this->hasSubscription(), fn () => [
'subscription' => new SubscriptionResource($this->subscription),
]),
- $this->mergeWhen($isMeteredSubscription, fn() => [
+ $this->mergeWhen($isMeteredSubscription, fn () => [
'balance' => new BalanceResource($this->balance),
]),
+ $this->mergeWhen($isMeteredSubscription, fn () => [
+ 'alert' => new BillingAlertResource($this->billingAlert),
+ ]),
],
'meta' => [
- $this->mergeWhen($isFixedSubscription, fn() => [
+ $this->mergeWhen($isFixedSubscription, fn () => [
'limitations' => $this->limitations->summary(),
]),
- $this->mergeWhen($isMeteredSubscription, fn() => [
+ $this->mergeWhen($isMeteredSubscription, fn () => [
'usages' => $this->getUsageEstimates(),
]),
],
diff --git a/src/Domain/Traffic/Models/Traffic.php b/src/Domain/Traffic/Models/Traffic.php
index b67866bc..026281d2 100644
--- a/src/Domain/Traffic/Models/Traffic.php
+++ b/src/Domain/Traffic/Models/Traffic.php
@@ -1,8 +1,8 @@
where('status', 'active')
->cursor()
- ->each(function($subscription) {
+ ->each(function ($subscription) {
$this->recordBandwidth($subscription);
$this->recordStorageCapacity($subscription);
});
@@ -46,4 +45,4 @@ class ReportUsageAction
// Record storage capacity usage
$subscription->recordUsage('bandwidth', $amount);
}
-}
\ No newline at end of file
+}
diff --git a/tests/App/Users/UserSubscriptionTest.php b/tests/App/Users/UserSubscriptionTest.php
index 587d5767..c89623f5 100644
--- a/tests/App/Users/UserSubscriptionTest.php
+++ b/tests/App/Users/UserSubscriptionTest.php
@@ -1,10 +1,9 @@
has(PlanFixedFeature::factory()
- ->count(2)
- ->sequence(
- [
- 'key' => 'max_storage_amount',
- 'value' => 200,
- ],
- [
- 'key' => 'max_team_members',
- 'value' => 20,
- ],
- ), 'fixedFeatures')
+ ->count(2)
+ ->sequence(
+ [
+ 'key' => 'max_storage_amount',
+ 'value' => 200,
+ ],
+ [
+ 'key' => 'max_team_members',
+ 'value' => 20,
+ ],
+ ), 'fixedFeatures')
->create();
$user = User::factory()
@@ -54,17 +53,17 @@ class UserSubscriptionTest extends TestCase
{
$plan = Plan::factory()
->has(PlanFixedFeature::factory()
- ->count(2)
- ->sequence(
- [
- 'key' => 'max_storage_amount',
- 'value' => 200,
- ],
- [
- 'key' => 'max_team_members',
- 'value' => 20,
- ],
- ), 'fixedFeatures')
+ ->count(2)
+ ->sequence(
+ [
+ 'key' => 'max_storage_amount',
+ 'value' => 200,
+ ],
+ [
+ 'key' => 'max_team_members',
+ 'value' => 20,
+ ],
+ ), 'fixedFeatures')
->create();
$user = User::factory()
@@ -111,13 +110,13 @@ class UserSubscriptionTest extends TestCase
$usages = collect([
[
'feature' => 'bandwidth',
- "amount" => 7546.96,
- "usage" => 26024,
+ 'amount' => 7546.96,
+ 'usage' => 26024,
], [
- "feature" => "storage",
- "amount" => 476.28,
- "usage" => 3969,
- ]
+ 'feature' => 'storage',
+ 'amount' => 476.28,
+ 'usage' => 3969,
+ ],
]);
// Format usage estimates
@@ -126,16 +125,16 @@ class UserSubscriptionTest extends TestCase
$expected = [
[
- "feature" => "bandwidth",
- "amount" => 7.54696,
- "cost" => "$7.55",
- "usage" => "26.02GB",
+ 'feature' => 'bandwidth',
+ 'amount' => 7.54696,
+ 'cost' => '$7.55',
+ 'usage' => '26.02GB',
], [
- "feature" => "storage",
- "amount" => 0.47628,
- "cost" => "$0.48",
- "usage" => "3.97GB",
- ]
+ 'feature' => 'storage',
+ 'amount' => 0.47628,
+ 'cost' => '$0.48',
+ 'usage' => '3.97GB',
+ ],
];
$this->assertEquals($expected, $estimates);
diff --git a/tests/Domain/Teams/TeamLimitsTest.php b/tests/Domain/Teams/TeamLimitsTest.php
index a0977878..51ffb32a 100644
--- a/tests/Domain/Teams/TeamLimitsTest.php
+++ b/tests/Domain/Teams/TeamLimitsTest.php
@@ -30,10 +30,10 @@ class TeamLimitsTest extends TestCase
$members->each(
fn ($member) => TeamFolderMember::factory()
- ->create([
- 'parent_id' => $user->folders[0]->id,
- 'user_id' => $member->id,
- ])
+ ->create([
+ 'parent_id' => $user->folders[0]->id,
+ 'user_id' => $member->id,
+ ])
);
// Try invite new member
diff --git a/tests/Domain/Traffic/TrafficTest.php b/tests/Domain/Traffic/TrafficTest.php
index c80f30cf..f40771b8 100644
--- a/tests/Domain/Traffic/TrafficTest.php
+++ b/tests/Domain/Traffic/TrafficTest.php
@@ -1,9 +1,6 @@
create([
- 'user_id' => $user->id,
- 'download' => 155000000,
+ 'user_id' => $user->id,
+ 'download' => 155000000,
'created_at' => now()->subDay(),
]);