feat(admin): IP pool allocation, billing exports, service attachments
- IP pool: sheet import (xlsx/csv) matched by address, bulk allocate/revoke with notification email (ip_allocated/ip_revoked), ip_pool_logs history. - Orders/invoices: Excel export on branded template (BrandedReportWriter), shared billing filters, order item service info in list responses. - Web design quote Excel export; activity log export. - Service attachments with copy-to-invoice; deployment invoice attachments. - Customer email attachments stored on disk and attached by path. - Admin password change endpoint; user.fullname backfill migration; orders.user_id backfill from logs. - Disable deploy workflow until CI/CD is set up. - Ignore stored customer email and service attachment uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ea5697cb81
commit
46aa138eec
@@ -5,6 +5,7 @@ namespace App\Repositories\ActivityLog;
|
||||
use App\Models\ActivityLog;
|
||||
use App\Repositories\BaseRepository;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ActivityLogRepository extends BaseRepository implements ActivityLogRepositoryInterface
|
||||
{
|
||||
@@ -14,6 +15,11 @@ class ActivityLogRepository extends BaseRepository implements ActivityLogReposit
|
||||
}
|
||||
|
||||
public function filter(array $filters, int $perPage = 20): LengthAwarePaginator
|
||||
{
|
||||
return $this->query($filters)->latest('id')->paginate($perPage);
|
||||
}
|
||||
|
||||
public function query(array $filters): Builder
|
||||
{
|
||||
$query = $this->model->newQuery();
|
||||
|
||||
@@ -61,6 +67,6 @@ class ActivityLogRepository extends BaseRepository implements ActivityLogReposit
|
||||
$query->where('description', 'like', '%' . $filters['search'] . '%');
|
||||
}
|
||||
|
||||
return $query->latest('id')->paginate($perPage);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ namespace App\Repositories\ActivityLog;
|
||||
|
||||
use App\Repositories\BaseRepositoryInterface;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
interface ActivityLogRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
public function filter(array $filters, int $perPage = 20): LengthAwarePaginator;
|
||||
|
||||
public function query(array $filters): Builder;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Concerns;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
trait FiltersBillingRecords
|
||||
{
|
||||
/**
|
||||
* @param array<string, int> $aliases
|
||||
*/
|
||||
private function whereStatus(Builder $query, mixed $status, array $aliases): Builder
|
||||
{
|
||||
$values = collect((array) $status)
|
||||
->reject(fn ($value) => $value === null || $value === '' || $value === 'full')
|
||||
->map(fn ($value) => $aliases[$value] ?? (int) $value)
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
return $values->isEmpty() ? $query : $query->whereIn('status', $values->all());
|
||||
}
|
||||
|
||||
private function whereCreatedBetween(Builder $query, ?string $from, ?string $to): Builder
|
||||
{
|
||||
return $query
|
||||
->when($from, fn (Builder $q) => $q->where('created_at', '>=', Carbon::parse($from)->startOfDay()))
|
||||
->when($to, fn (Builder $q) => $q->where('created_at', '<=', Carbon::parse($to)->endOfDay()));
|
||||
}
|
||||
|
||||
private function whereOrderItemNameLike(Builder $query, string $orderItemsRelation, string $search): Builder
|
||||
{
|
||||
return $query->orWhereHas($orderItemsRelation, fn (Builder $items) => $items
|
||||
->where('server_name', 'like', "%{$search}%")
|
||||
->orWhere('domain_name', 'like', "%{$search}%"));
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,7 @@ class EmployeeRepository extends BaseRepository implements EmployeeRepositoryInt
|
||||
if (!empty($data['search'])) {
|
||||
$search = $data['search'];
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('firstname', 'like', "%{$search}%")
|
||||
->orWhere('lastname', 'like', "%{$search}%")
|
||||
$q->where('fullname', 'like', "%{$search}%")
|
||||
->orWhere('username', 'like', "%{$search}%")
|
||||
->orWhere('email', 'like', "%{$search}%");
|
||||
});
|
||||
|
||||
@@ -4,10 +4,13 @@ namespace App\Repositories\Invoice;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Repositories\BaseRepository;
|
||||
use App\Repositories\Concerns\FiltersBillingRecords;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInterface
|
||||
{
|
||||
use FiltersBillingRecords;
|
||||
|
||||
public function getModel()
|
||||
{
|
||||
return Invoice::class;
|
||||
@@ -58,11 +61,18 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
);
|
||||
});
|
||||
}
|
||||
if (isset($data['status']) && $data['status'] !=='full') {
|
||||
$model = $model->where('status', match ($data['status']) {
|
||||
'active' => 1,
|
||||
'cancel' => 2,
|
||||
default => 0
|
||||
$model = $this->whereStatus($model, $data['status'] ?? null, ['unpaid' => 1, 'paid' => 2, 'cancel' => 3, 'overdue' => 4, 'refunded' => 5]);
|
||||
$model = $this->whereCreatedBetween($model, $data['date_from'] ?? null, $data['date_to'] ?? null);
|
||||
if (isset($data['filter']) && $data['filter'] !== '') {
|
||||
$search = $data['filter'];
|
||||
$model = $model->where(function ($query) use ($search) {
|
||||
$query->where('invoice_number', 'like', "%{$search}%")
|
||||
->orWhereHas('order', fn ($query) => $query->where('order_num', 'like', "%{$search}%"))
|
||||
->orWhereHas('customer', function ($query) use ($search) {
|
||||
$query->where('fullname', 'like', "%{$search}%")
|
||||
->orWhere('email', 'like', "%{$search}%");
|
||||
});
|
||||
$this->whereOrderItemNameLike($query, 'order.orderItems', $search);
|
||||
});
|
||||
}
|
||||
if (isset($data['relations'])) {
|
||||
|
||||
@@ -4,10 +4,13 @@ namespace App\Repositories\Order;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Repositories\BaseRepository;
|
||||
use App\Repositories\Concerns\FiltersBillingRecords;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class OrderRepository extends BaseRepository implements OrderRepositoryInterface
|
||||
{
|
||||
use FiltersBillingRecords;
|
||||
|
||||
public function getModel()
|
||||
{
|
||||
return Order::class;
|
||||
@@ -54,15 +57,13 @@ class OrderRepository extends BaseRepository implements OrderRepositoryInterface
|
||||
$model = $model->where("invoice_id", $data['invoice_id']);
|
||||
}
|
||||
}
|
||||
if (isset($data['status']) && $data['status'] !== '' && $data['status'] !== null && $data['status'] != 'full') {
|
||||
$status = match ($data['status']) {
|
||||
'active' => 1,
|
||||
'pending' => 0,
|
||||
'processing' => 3,
|
||||
'cancel' => 2,
|
||||
default => $data['status'],
|
||||
};
|
||||
$model = $model->where("status", $status);
|
||||
$model = $this->whereStatus($model, $data['status'] ?? null, ['active' => 1, 'pending' => 0, 'processing' => 3, 'cancel' => 2]);
|
||||
$model = $this->whereCreatedBetween($model, $data['date_from'] ?? null, $data['date_to'] ?? null);
|
||||
if (! empty($data['customer_id'])) {
|
||||
$model = $model->where('customer_id', $data['customer_id']);
|
||||
}
|
||||
if (! empty($data['payment_method'])) {
|
||||
$model = $model->where('payment_method', $data['payment_method']);
|
||||
}
|
||||
|
||||
if (isset($data['filter']) && $data['filter'] !== '') {
|
||||
@@ -73,6 +74,7 @@ class OrderRepository extends BaseRepository implements OrderRepositoryInterface
|
||||
$query->where('fullname', 'like', "%{$search}%")
|
||||
->orWhere('email', 'like', "%{$search}%");
|
||||
});
|
||||
$this->whereOrderItemNameLike($query, 'orderItems', $search);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user