Giant Update
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Billing;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BillingProfileResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [...parent::toArray($request), 'tenant' => $this->whenLoaded('tenant')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Billing;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
...parent::toArray($request),
|
||||
'tenant' => $this->whenLoaded('tenant'),
|
||||
'customer' => $this->whenLoaded('customer'),
|
||||
'billing_profile' => $this->whenLoaded('billingProfile'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Customer;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomerResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
unset($data['images'], $data['cover_image']);
|
||||
|
||||
return [
|
||||
...$data,
|
||||
'tenant' => $this->whenLoaded('tenant'),
|
||||
'provinsi' => $this->whenLoaded('provinsi'),
|
||||
'kabupaten' => $this->whenLoaded('kabupaten'),
|
||||
'kecamatan' => $this->whenLoaded('kecamatan'),
|
||||
'desa' => $this->whenLoaded('desa'),
|
||||
'package_profile' => $this->whenLoaded('packageProfile'),
|
||||
'nas_mikrotik' => $this->whenLoaded('nasMikrotik'),
|
||||
'billing_profile' => $this->whenLoaded('billingProfile'),
|
||||
'images' => $this->whenLoaded('images', fn () => $this->images->map(fn ($image) => [
|
||||
'id' => $image->id,
|
||||
'stored_file_id' => $image->stored_file_id,
|
||||
'uuid' => $image->file?->uuid,
|
||||
'original_name' => $image->file?->original_name,
|
||||
'category' => $image->category,
|
||||
'caption' => $image->caption,
|
||||
'is_cover' => $image->is_cover,
|
||||
'sort_order' => $image->sort_order,
|
||||
])->values()),
|
||||
'cover_image' => $this->whenLoaded('coverImage', fn () => $this->coverImage ? [
|
||||
'stored_file_id' => $this->coverImage->stored_file_id,
|
||||
'uuid' => $this->coverImage->file?->uuid,
|
||||
'original_name' => $this->coverImage->file?->original_name,
|
||||
'size' => $this->coverImage->file?->size,
|
||||
] : null),
|
||||
'full_installation_address' => collect([
|
||||
$this->installation_address,
|
||||
$this->desa?->nama,
|
||||
$this->kecamatan?->nama,
|
||||
$this->kabupaten?->nama,
|
||||
$this->provinsi?->nama,
|
||||
])->filter()->implode(', '),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Notification;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class NotificationDeliveryResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$destination = (string) $this->destination;
|
||||
$masked = strlen($destination) > 6
|
||||
? substr($destination, 0, 3).str_repeat('*', max(3, strlen($destination) - 6)).substr($destination, -3)
|
||||
: str_repeat('*', strlen($destination));
|
||||
|
||||
return [
|
||||
...parent::toArray($request),
|
||||
'destination' => $masked,
|
||||
'message' => $this->whenLoaded('message'),
|
||||
'channel_config' => $this->whenLoaded('channelConfig'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Payment;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PaymentTransactionResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id, 'uuid' => $this->uuid, 'transaction_number' => $this->transaction_number,
|
||||
'tenant' => $this->whenLoaded('tenant'), 'user' => $this->whenLoaded('user'),
|
||||
'customer' => $this->whenLoaded('customer'), 'invoice' => $this->whenLoaded('invoice'),
|
||||
'provider' => $this->account?->provider, 'gateway_scope' => $this->gateway_scope,
|
||||
'purpose' => $this->purpose, 'method' => $this->method, 'amount' => $this->amount,
|
||||
'provider_fee' => $this->provider_fee, 'platform_fee' => $this->platform_fee,
|
||||
'total_amount' => $this->total_amount, 'currency' => $this->currency, 'status' => $this->status,
|
||||
'provider_status' => $this->provider_status, 'provider_reference' => $this->provider_reference,
|
||||
'expires_at' => $this->expires_at, 'paid_at' => $this->paid_at, 'created_at' => $this->created_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Topology;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TopologyResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
...parent::toArray($request),
|
||||
'tenant' => $this->whenLoaded('tenant'),
|
||||
'device_type' => $this->whenLoaded('deviceType'),
|
||||
'parent' => $this->whenLoaded('parent'),
|
||||
'ports' => $this->whenLoaded('ports'),
|
||||
'source_node' => $this->whenLoaded('sourceNode'),
|
||||
'target_node' => $this->whenLoaded('targetNode'),
|
||||
'source_port' => $this->whenLoaded('sourcePort'),
|
||||
'target_port' => $this->whenLoaded('targetPort'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user