feat: Implement new admin API endpoints for product, customer, vCenter, and authentication, and add vCenter resource management UI.

This commit is contained in:
pbao9
2026-03-05 14:30:31 +07:00
parent 68540009c0
commit cca4e0b86f
47 changed files with 3538 additions and 1086 deletions
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Resources\Api\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class AdminUserResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'username' => $this->username,
'email' => $this->email,
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'roles' => $this->getRoleNames(),
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources\Api\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class CustomerResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'fullname' => $this->fullname,
'email' => $this->email,
'phone' => $this->phone,
'company' => $this->company,
'status' => match ((int) $this->status) {
1 => 'active',
2 => 'inactive',
3 => 'suspended',
default => 'pending',
},
'total' => (int) $this->total,
'created_at' => $this->created_at,
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources\Api\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'order_num' => $this->order_num,
'customer' => $this->whenLoaded('customer', fn() => [
'id' => $this->customer->id,
'fullname' => $this->customer->fullname,
'email' => $this->customer->email,
]),
'sub_total' => $this->sub_total,
'tax' => $this->tax,
'total' => $this->total,
'status' => $this->status,
'date' => $this->date,
'due_date' => $this->due_date,
'date_paid' => $this->date_paid,
'created_at' => $this->created_at,
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources\Api\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'order_num' => $this->order_num,
'customer' => $this->whenLoaded('customer', fn() => [
'id' => $this->customer->id,
'fullname' => $this->customer->fullname,
'email' => $this->customer->email,
]),
'amount' => $this->amount,
'status' => $this->status,
'date' => $this->date,
'created_at' => $this->created_at,
];
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources\Api\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductResource extends JsonResource
{
public function toArray(Request $request): array
{
$minPrice = $this->whenLoaded('pricings', function () {
return $this->pricings->min('price');
});
return [
'id' => $this->id,
'uuid' => $this->uuid,
'name' => $this->name,
'product_type' => $this->product_type,
'category' => $this->whenLoaded('category', fn() => $this->category?->name),
'cpu' => $this->cpu,
'ram' => $this->ram,
'disk' => $this->disk,
'bandwidth' => $this->bandwidth,
'setup_fee' => $this->setup_fee,
'min_price' => $minPrice,
'is_active' => $this->is_active,
'created_at' => $this->created_at,
];
}
}