Import not working..

When I try to import, It's showing a blank popup. No error in log file. What can be the reason ? Any idea ?
6 Replies
Yuvraj Timalsina
@Saifulapm any additional context as you've only shared a blackout video 😅
Saifulapm
SaifulapmOP2w ago
Importer
class SupplierImporter extends Importer
{
protected static ?string $model = Supplier::class;

public static function getColumns(): array
{
return [
ImportColumn::make('name')->requiredMapping(),
];
}

public function resolveRecord(): ?Supplier
{
Log::info('Import data:', $this->data);

return Supplier::firstOrNew([
// Update existing records, matching them by `$this->data['column_name']`
'name' => $this->data['name'],
]);
}

public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your supplier import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';

if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
}

return $body;
}
}
class SupplierImporter extends Importer
{
protected static ?string $model = Supplier::class;

public static function getColumns(): array
{
return [
ImportColumn::make('name')->requiredMapping(),
];
}

public function resolveRecord(): ?Supplier
{
Log::info('Import data:', $this->data);

return Supplier::firstOrNew([
// Update existing records, matching them by `$this->data['column_name']`
'name' => $this->data['name'],
]);
}

public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your supplier import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';

if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
}

return $body;
}
}
Model
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Supplier extends Model
{
protected $guarded = [];

protected $casts = [
'custom' => 'array',
];

public function products()
{
return $this->hasMany(Product::class);
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Supplier extends Model
{
protected $guarded = [];

protected $casts = [
'custom' => 'array',
];

public function products()
{
return $this->hasMany(Product::class);
}
}
Migration
Schema::create('suppliers', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->json('custom')->nullable();
$table->timestamps();
});
Schema::create('suppliers', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->json('custom')->nullable();
$table->timestamps();
});
Let me know if you need anything else. @Yuvraj Timalsina
Yuvraj Timalsina
Seems alright, you may have queue running as well env configured properly as well. Try once by removing required mapping.
Saifulapm
SaifulapmOP2w ago
I tried. Also queue runing. Is it related with unique index ?
Yuvraj Timalsina
You should have logs, it would be great if you could replicate and share access to the repo
Dennis Koch
Dennis Koch2w ago
Check what response is returned from your server via DevTools network tab
Want results from more Discord servers?
Add your server