mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-24 01:50:38 +00:00
- Create/Update metered billing plan
This commit is contained in:
@@ -12,12 +12,21 @@ class ReportUsageAction
|
||||
->where('status', 'active')
|
||||
->cursor()
|
||||
->each(function ($subscription) {
|
||||
$this->recordBandwidth($subscription);
|
||||
$this->recordStorageCapacity($subscription);
|
||||
if ($subscription->plan->meteredFeatures()->where('key', 'bandwidth')->exists()) {
|
||||
$this->recordBandwidth($subscription);
|
||||
}
|
||||
|
||||
if ($subscription->plan->meteredFeatures()->where('key', 'storage')->exists()) {
|
||||
$this->recordStorageUsage($subscription);
|
||||
}
|
||||
|
||||
if ($subscription->plan->meteredFeatures()->where('key', 'flatFee')->exists()) {
|
||||
$this->recordFlatFee($subscription);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function recordStorageCapacity(Subscription $subscription): void
|
||||
private function recordStorageUsage(Subscription $subscription): void
|
||||
{
|
||||
// Sum all file size
|
||||
$filesize = DB::table('files')
|
||||
@@ -45,4 +54,10 @@ class ReportUsageAction
|
||||
// Record storage capacity usage
|
||||
$subscription->recordUsage('bandwidth', $amount);
|
||||
}
|
||||
|
||||
private function recordFlatFee(Subscription $subscription): void
|
||||
{
|
||||
// Record flat fee
|
||||
$subscription->recordUsage('flatFee', 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user