- Created ExampleTest and RoutesTest for basic application response and route testing. - Implemented IsolatedDatabaseTestCase for isolated database testing. - Added unit tests for various models and services including Contract, CPE, and LeadDetail. - Developed request validation tests for CreateClientRequest, UpdateClientRequest, and ContractRequest. - Introduced Vite configuration for asset management in the Laravel application.
53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Models\Contract;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class ContractsExport implements FromCollection, WithHeadings
|
|
{
|
|
public function collection()
|
|
{
|
|
return Contract::with(['client', 'seller'])->get()->map(function ($contract) {
|
|
return [
|
|
'Client' => $contract->client->name ?? '',
|
|
'Seller' => $contract->seller->name ?? '',
|
|
'Code' => $contract->code,
|
|
'Supply Type' => strtoupper($contract->supply_type),
|
|
'Power/CUI' => $contract->supply_type === 'cpe'
|
|
? ($contract->powerTier->name ?? '')
|
|
: ($contract->cuiTier->name ?? ''),
|
|
'Consumption' => $contract->annual_consumption ?? '',
|
|
'Contract Type'=> $contract->contractType->description ?? '',
|
|
'PVP' => $contract->contract_value,
|
|
'Commission' => $contract->commission_value,
|
|
'Status' => $contract->status->description ?? '',
|
|
'Activation' => optional($contract->activation_date)->format('d/m/Y'),
|
|
'Validity' => optional($contract->validity)->format('d/m/Y'),
|
|
'Contract End' => optional($contract->contract_end_date)->format('d/m/Y'),
|
|
];
|
|
});
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Cliente',
|
|
'Vendedor',
|
|
'Código',
|
|
'Tipo Fornecimento',
|
|
'Potência / Escalão',
|
|
'Consumo Anual',
|
|
'Tipo Contrato',
|
|
'PVP',
|
|
'Comissão',
|
|
'Estado',
|
|
'Data Ativação',
|
|
'Validade',
|
|
'Fim de Contrato',
|
|
];
|
|
}
|
|
}
|