mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-14 09:15:01 +00:00
test refactoring
This commit is contained in:
@@ -45,6 +45,9 @@ class GenerateDemoSubscriptionContentCommand extends Command
|
||||
|
||||
// Create plans and subscriptions for fixed billing
|
||||
if ($this->argument('type') === 'fixed') {
|
||||
|
||||
// TODO: check for credentials
|
||||
|
||||
$this->info('Setting up new fixed plans demo data...');
|
||||
$this->generateFixedPlans();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class AutoSubscribeForMeteredBillingAction
|
||||
} else {
|
||||
// Create balance with 0 amount
|
||||
$user->balance()->create([
|
||||
'amount' => 0,
|
||||
'amount' => 0,
|
||||
'currency' => $plan->currency,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace App\Users\Actions;
|
||||
|
||||
use App\Users\DTO\CreateUserData;
|
||||
use App\Users\Models\User;
|
||||
use App\Users\DTO\CreateUserData;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
|
||||
@@ -10,7 +10,8 @@ class RegisterUserController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public CreateNewUserAction $createNewUser,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(RegisterUserRequest $request)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Resources;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -22,18 +20,18 @@ class UserStorageResource extends JsonResource
|
||||
|
||||
$totalCapacity = match (get_settings('subscription_type')) {
|
||||
'metered' => $this->usedCapacity / 1000000000,
|
||||
'fixed' => $this->limitations->max_storage_amount,
|
||||
default => $this->limitations->max_storage_amount,
|
||||
'fixed' => $this->limitations->max_storage_amount,
|
||||
default => $this->limitations->max_storage_amount,
|
||||
};
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'id' => (string) $this->id,
|
||||
'type' => 'storage',
|
||||
'attributes' => [
|
||||
'used' => Metric::bytes($this->usedCapacity)->format(),
|
||||
'capacity' => format_gigabytes($totalCapacity),
|
||||
'percentage' => (float)get_storage_percentage($this->usedCapacity, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($this->usedCapacity, $totalCapacity),
|
||||
],
|
||||
'meta' => [
|
||||
'traffic' => [
|
||||
@@ -46,23 +44,23 @@ class UserStorageResource extends JsonResource
|
||||
],
|
||||
'images' => [
|
||||
'used' => Metric::bytes($images)->format(),
|
||||
'percentage' => (float)get_storage_percentage($images, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($images, $totalCapacity),
|
||||
],
|
||||
'audios' => [
|
||||
'used' => Metric::bytes($audios)->format(),
|
||||
'percentage' => (float)get_storage_percentage($audios, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($audios, $totalCapacity),
|
||||
],
|
||||
'videos' => [
|
||||
'used' => Metric::bytes($videos)->format(),
|
||||
'percentage' => (float)get_storage_percentage($videos, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($videos, $totalCapacity),
|
||||
],
|
||||
'documents' => [
|
||||
'used' => Metric::bytes($documents)->format(),
|
||||
'percentage' => (float)get_storage_percentage($documents, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($documents, $totalCapacity),
|
||||
],
|
||||
'others' => [
|
||||
'used' => Metric::bytes($others)->format(),
|
||||
'percentage' => (float)get_storage_percentage($others, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($others, $totalCapacity),
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -134,12 +132,12 @@ class UserStorageResource extends JsonResource
|
||||
->orderBy('created_at')
|
||||
->get();
|
||||
|
||||
$upload = $trafficRecords->map(fn($record) => [
|
||||
$upload = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at),
|
||||
'amount' => $uploadMax !== 0 ? round(($record->upload / $uploadMax) * 100, 2) : 0,
|
||||
]);
|
||||
|
||||
$download = $trafficRecords->map(fn($record) => [
|
||||
$download = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at),
|
||||
'amount' => $downloadMax !== 0 ? round(($record->download / $downloadMax) * 100, 2) : 0,
|
||||
]);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Admin\Controllers\Dashboard;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
||||
|
||||
class GetDashboardDataController extends Controller
|
||||
@@ -61,16 +60,17 @@ class GetDashboardDataController extends Controller
|
||||
->select(
|
||||
DB::raw('DATE(created_at) as created_at'),
|
||||
DB::raw('sum(download) as download'),
|
||||
DB::raw('sum(upload) as upload'))
|
||||
DB::raw('sum(upload) as upload')
|
||||
)
|
||||
->groupBy('created_at')
|
||||
->get();
|
||||
|
||||
$upload = $trafficRecords->map(fn($record) => [
|
||||
$upload = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B. %Y'),
|
||||
'amount' => intval($trafficRecords->max('upload')) !== 0 ? round(($record->upload / $trafficRecords->max('upload')) * 100, 2) : 0,
|
||||
]);
|
||||
|
||||
$download = $trafficRecords->map(fn($record) => [
|
||||
$download = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B. %Y'),
|
||||
'amount' => intval($trafficRecords->max('download')) !== 0 ? round(($record->download / $trafficRecords->max('download')) * 100, 2) : 0,
|
||||
]);
|
||||
|
||||
@@ -27,11 +27,11 @@ class StoreSocialServiceCredentialsController
|
||||
if (! app()->runningUnitTests()) {
|
||||
$credentials = [
|
||||
'facebook' => [
|
||||
'FACEBOOK_CLIENT_ID' => $request->input('client_id'),
|
||||
'FACEBOOK_CLIENT_ID' => $request->input('client_id'),
|
||||
'FACEBOOK_CLIENT_SECRET' => $request->input('client_secret'),
|
||||
],
|
||||
'google' => [
|
||||
'GOOGLE_CLIENT_ID' => $request->input('client_id'),
|
||||
'GOOGLE_CLIENT_ID' => $request->input('client_id'),
|
||||
'GOOGLE_CLIENT_SECRET' => $request->input('client_secret'),
|
||||
],
|
||||
'github' => [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
Reference in New Issue
Block a user