Saifulapm
Saifulapm
Explore posts from servers
FFilament
Created by Saifulapm on 12/8/2024 in #❓┊help
Import not working..
I tried. Also queue runing. Is it related with unique index ?
8 replies
FFilament
Created by Saifulapm on 12/8/2024 in #❓┊help
Import not working..
@Yuvraj Timalsina
8 replies
FFilament
Created by Saifulapm on 12/8/2024 in #❓┊help
Import not working..
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.
8 replies
FFilament
Created by Jr.Pikong on 1/19/2024 in #❓┊help
Export with custom guard
@Jr.Pikong when try to download export file, it’s not working because of custom guard. How did you make it ??
7 replies
FFilament
Created by Saifulapm on 4/19/2024 in #❓┊help
Using a custom user model in Export action
How I can add admin model to export ?
7 replies
FFilament
Created by Saifulapm on 4/19/2024 in #❓┊help
Using a custom user model in Export action
But when export finished, notification should be send to admin model ..
7 replies
FFilament
Created by Saifulapm on 4/19/2024 in #❓┊help
Using a custom user model in Export action
Still I need to register it ??
7 replies
FFilament
Created by Saifulapm on 4/19/2024 in #❓┊help
Using a custom user model in Export action
My Admin model extend to User model
class Admin extends User
{
use HasRoles, HasSuperAdmin;

protected $table = 'users';

protected static function booted()
{
static::addGlobalScope('admin', function (Builder $builder) {
$builder->where('type', 'admin');
});
}
}
class Admin extends User
{
use HasRoles, HasSuperAdmin;

protected $table = 'users';

protected static function booted()
{
static::addGlobalScope('admin', function (Builder $builder) {
$builder->where('type', 'admin');
});
}
}
7 replies
CDCloudflare Developers
Created by Saifulapm on 11/14/2023 in #general-help
how to add border with Cloudflare Inages
Any idea how can I use with cloudflare worker ? Right now I can only work use flexiable variants by url params. But don’t know how to add border ?
3 replies
CDCloudflare Developers
Created by Saifulapm on 11/14/2023 in #general-help
how to add border with Cloudflare Inages
Yes. I have cloudflare image plan.
3 replies