mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-26 10:30:38 +00:00
removed old subscription backend
This commit is contained in:
@@ -10,10 +10,6 @@ class GetWidgetsValuesController extends Controller
|
||||
{
|
||||
public function __invoke(): array
|
||||
{
|
||||
// Get total premium users
|
||||
$premium_users = Subscription::whereStripeStatus('active')
|
||||
->count();
|
||||
|
||||
// Get total storage usage
|
||||
$storage_usage = Metric::bytes(
|
||||
\DB::table('files')->sum('filesize')
|
||||
@@ -24,7 +20,6 @@ class GetWidgetsValuesController extends Controller
|
||||
'app_version' => config('vuefilemanager.version'),
|
||||
'total_users' => User::count(),
|
||||
'total_used_space' => $storage_usage,
|
||||
'total_premium_users' => $premium_users,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@ class DeleteUserController extends Controller
|
||||
return response('Done.', 204);
|
||||
}
|
||||
|
||||
if ($user->subscribed('main')) {
|
||||
// TODO: secure deletion
|
||||
/*if ($user->subscription) {
|
||||
abort(202, "You can\'t delete this account while user have active subscription.");
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($user->id === Auth::id()) {
|
||||
abort(406, "You can\'t delete your account");
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Admin\Controllers\Users;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Invoices\Resources\InvoiceCollection;
|
||||
use Domain\Subscriptions\Services\StripeService;
|
||||
|
||||
class ShowUserInvoicesController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private StripeService $stripe
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*/
|
||||
public function __invoke(User $user): InvoiceCollection
|
||||
{
|
||||
$invoices = $this->stripe->getUserInvoices($user);
|
||||
|
||||
return new InvoiceCollection($invoices);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Admin\Controllers\Users;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Users\Resources\UserSubscription;
|
||||
|
||||
class ShowUserSubscriptionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get user subscription details
|
||||
*/
|
||||
public function __invoke(User $user): UserSubscription | Response
|
||||
{
|
||||
if (! $user->stripeId() || ! $user->subscription('main')) {
|
||||
return response("User doesn't have any subscription.", 404);
|
||||
}
|
||||
|
||||
return new UserSubscription($user);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Admin\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class InvoiceAdminCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = InvoiceAdminResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Admin\Resources;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Laravel\Cashier\Cashier;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceAdminResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$user = User::where('stripe_id', $this['customer'])
|
||||
->first();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this['id'],
|
||||
'type' => 'invoices',
|
||||
'attributes' => [
|
||||
'customer' => $this['customer'],
|
||||
'total' => Cashier::formatAmount($this['total']),
|
||||
'currency' => $this['currency'],
|
||||
'created_at_formatted' => format_date($this['created']),
|
||||
'created_at' => $this['created'],
|
||||
'order' => $this['number'],
|
||||
'user_id' => $user->id ?? null,
|
||||
'client' => [
|
||||
'billing_address' => $this['customer_address'],
|
||||
'billing_name' => $this['customer_name'],
|
||||
'billing_phone_number' => $this['customer_phone'],
|
||||
],
|
||||
'bag' => [
|
||||
'amount' => $this['lines']['data'][0]['amount'],
|
||||
'currency' => $this['lines']['data'][0]['currency'],
|
||||
'type' => $this['lines']['data'][0]['type'],
|
||||
'description' => $this['lines']['data'][0]['description'],
|
||||
],
|
||||
'seller' => null,
|
||||
],
|
||||
$this->mergeWhen($user, function () use ($user) {
|
||||
return [
|
||||
'relationships' => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'id' => $user->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'name' => $user->settings->name,
|
||||
'avatar' => $user->settings->avatar,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user