Added plant code instead of plant name on import and export
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -14,39 +14,40 @@ class MfmMeterExporter extends Exporter
|
|||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
static $rowNumber = 0;
|
static $rowNumber = 0;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
ExportColumn::make('no')
|
ExportColumn::make('no')
|
||||||
->label('NO')
|
->label('NO')
|
||||||
->state(function ($record) use (&$rowNumber) {
|
->state(function ($record) use (&$rowNumber) {
|
||||||
// Increment and return the row number
|
// Increment and return the row number
|
||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.name')
|
ExportColumn::make('plant.code')
|
||||||
->label('PLANT'),
|
->label('PLANT CODE'),
|
||||||
ExportColumn::make('device.name')
|
ExportColumn::make('device.name')
|
||||||
->label('DEVICE NAME'),
|
->label('DEVICE NAME'),
|
||||||
ExportColumn::make('sequence')
|
ExportColumn::make('sequence')
|
||||||
->label('SEQUENCE'),
|
->label('SEQUENCE'),
|
||||||
ExportColumn::make('name')
|
ExportColumn::make('name')
|
||||||
->label('NAME'),
|
->label('METER NAME'),
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
->label('CREATED AT'),
|
->label('CREATED AT'),
|
||||||
ExportColumn::make('updated_at')
|
ExportColumn::make('updated_at')
|
||||||
->label('UPDATED AT'),
|
->label('UPDATED AT'),
|
||||||
ExportColumn::make('deleted_at')
|
ExportColumn::make('deleted_at')
|
||||||
->label('DELETED AT')
|
->label('DELETED AT')
|
||||||
->enabledByDefault(false),
|
->enabledByDefault(false),
|
||||||
ExportColumn::make('created_by')
|
ExportColumn::make('created_by')
|
||||||
->label('CREATED BY'),
|
->label('CREATED BY'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
{
|
{
|
||||||
$body = 'Your mfm meter export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
$body = 'Your mfm meter export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
|
|||||||
@@ -15,18 +15,18 @@ class MfmMeterImporter extends Importer
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Code')
|
||||||
->example('Ransar Industries-I')
|
->example('1000')
|
||||||
->label('Plant Name')
|
->label('Plant Code')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('Device Name')
|
ImportColumn::make('Device Name')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Device Name')
|
->exampleHeader('Device Name')
|
||||||
->example('REG001')
|
->example('REG001')
|
||||||
->label('Device Name')
|
->label('Device Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing: 'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('sequence')
|
ImportColumn::make('sequence')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -56,15 +56,15 @@ class MfmMeterImporter extends Importer
|
|||||||
// 'email' => $this->data['email'],
|
// 'email' => $this->data['email'],
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
return new MfmMeter();
|
return new MfmMeter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
{
|
{
|
||||||
$body = 'Your mfm meter import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
$body = 'Your mfm meter import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
|
|||||||
Reference in New Issue
Block a user