PHP code example of martin6363 / filament-smart-import

1. Go to this page and download the library: Download martin6363/filament-smart-import library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

martin6363 / filament-smart-import example snippets


use Martin6363\FilamentSmartImport\FilamentSmartImportPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentSmartImportPlugin::make(),
        ]);
}

use App\Models\Article;
use Martin6363\FilamentSmartImport\Actions\SmartImportAction;

protected function getHeaderActions(): array
{
    return [
        SmartImportAction::make()
            ->model(Article::class)
            ->translatable(['title', 'content'])
            ->locales(['en', 'ru'])
            ->uniqueBy('id')
            ->validationRules([
                'title.en' => ['

use App\Models\Vehicle;
use Martin6363\FilamentSmartImport\Actions\SmartImportAction;

protected function getHeaderActions(): array
{
    return [
        SmartImportAction::make()
            ->model(Vehicle::class)
            ->uniqueBy('name_en')
            ->validationRules([
                'name_en' => ['

class Vehicle extends Model
{
    protected $fillable = [
        'name_en',
        'name_hy',
        'description_en',
        'description_hy',
        'is_available',
    ];

    protected function casts(): array
    {
        return [
            'is_available' => 'boolean',
        ];
    }
}

use App\Models\Category;

SmartImportAction::make()
    ->model(Article::class)
    ->relations([
        'category_id' => [Category::class => 'slug'],
    ]);

'category_id' => [Category::class => ['slug', 'name']],

use App\Models\Vehicle;
use Martin6363\FilamentSmartImport\Actions\SmartImportAction;

SmartImportAction::make()
    ->model(Vehicle::class)
    ->uniqueBy('name_en')
    ->validationRules([
        'name_en' => ['

->uniqueBy(['sku', 'warehouse_code'])

SmartImportAction::make()
    ->model(Article::class)
    ->translatable(['title', 'content'])
    ->locales(['en', 'ru'])
    ->uniqueBy('id')
    ->validationRules([
        'title.en' => ['

[
    'update_existing' => true,
    'unique_by' => ['name_en'],
]

'title.en' => [''nullable', 'string'],

'name_en' => [''nullable', 'string', 'max:255'],
bash
php artisan migrate
bash
php artisan filament:assets
bash
php artisan queue:work