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
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Enums\Invoice\InvoiceStatus;
|
||||
use App\Traits\LogsActivity;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -41,6 +42,26 @@ class Invoice extends Model
|
||||
return '/hoa-don/' . ($this->order?->order_num ?? $this->invoice_number);
|
||||
}
|
||||
|
||||
/** @param iterable<Service> $services */
|
||||
public function scopeOfServices(Builder $query, iterable $services): Builder
|
||||
{
|
||||
$services = collect($services);
|
||||
$orderIds = $services->map(fn (Service $service) => $service->orderItem?->order_id)->filter()->unique()->values();
|
||||
|
||||
return $query->where(fn (Builder $q) => $q
|
||||
->whereIn('service_id', $services->pluck('id'))
|
||||
->orWhere(fn (Builder $q) => $q->whereNull('service_id')->whereIn('order_id', $orderIds)));
|
||||
}
|
||||
|
||||
public function belongsToService(Service $service): bool
|
||||
{
|
||||
if ($this->service_id !== null) {
|
||||
return (int) $this->service_id === (int) $service->id;
|
||||
}
|
||||
|
||||
return $this->order_id !== null && (int) $this->order_id === (int) $service->orderItem?->order_id;
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id');
|
||||
|
||||
Reference in New Issue
Block a user