31 lines
872 B
PHP
31 lines
872 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\ClientInvoice;
|
|
use App\Services\ClientInvoicePaymentSyncService;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class ClientInvoicePaymentItemBackfillSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$syncService = app(ClientInvoicePaymentSyncService::class);
|
|
$syncService->ensureDefaultItemTypes();
|
|
|
|
ClientInvoice::query()
|
|
->whereDoesntHave('payments')
|
|
->where(function ($query) {
|
|
$query
|
|
->whereNotNull('media_fee')
|
|
->orWhereNotNull('management_fee');
|
|
})
|
|
->orderBy('id')
|
|
->chunkById(100, function ($invoices) use ($syncService) {
|
|
foreach ($invoices as $invoice) {
|
|
$syncService->syncLegacyFees($invoice);
|
|
}
|
|
});
|
|
}
|
|
}
|