mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 03:10:51 +00:00
set/update/delete billing alert
This commit is contained in:
@@ -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),
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Actions;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
@@ -10,11 +9,10 @@ class FormatUsageEstimatesAction
|
||||
public function __invoke(string $currency, Collection $usage)
|
||||
{
|
||||
return $usage->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
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Resources;
|
||||
|
||||
use App\Users\Actions\FormatUsageEstimatesAction;
|
||||
use Domain\Folders\Resources\FolderCollection;
|
||||
use VueFileManager\Subscription\Domain\Usage\Actions\SumUsageForCurrentPeriodAction;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Users\Actions\FormatUsageEstimatesAction;
|
||||
use VueFileManager\Subscription\Domain\Credits\Resources\BalanceResource;
|
||||
use VueFileManager\Subscription\Domain\BillingAlerts\Resources\BillingAlertResource;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Resources\SubscriptionResource;
|
||||
use VueFileManager\Subscription\Domain\Usage\Actions\SumUsageForCurrentPeriodAction;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
@@ -41,18 +41,21 @@ class UserResource extends JsonResource
|
||||
'relationships' => [
|
||||
'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(),
|
||||
]),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user