Giter VIP home page Giter VIP logo

filament-import's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

filament-import's Issues

handleRecordCreation is not working

how do i work with this function that is added in the documentation?
do you have an alternative function?

my case is that i want to save ['created_by'] = Auth::id() with each row saved
how do i do that?

Import Action: Undefined array key 0

I installed the package and tried to import an excel file into the database, and I got an error:

image

This is my environments:

  • PHP 8.x
  • Filament v2.x
  • Laravel 9.x

I figured out what was wrong and found a bug at ImportAction.php, this is because this PR (#9)

$selectedField->each(function ($key, $value) use (&$prepareInsert) {
    $prepareInsert[$key] = $this->fields[$key]?->doMutateBeforeCreate($value);
});

Please review my approach to solve the problem here (#13)

"Could Not Find Zip Member" Error

Whenever I attempt to import a spreadsheet I get the following error message:
Could not find zip member zip:///srv/app/storage/framework/cache/laravel-excel/{filename}.xlsx#_rels.rels

Example:
Could not find zip member zip:///srv/app/storage/framework/cache/laravel-excel/laravel-excel-mWjJtWdvcNkTQpfOJwJyuOkIYUAJNRT7.xlsx#_rels.rels

This issue only came about after I upgraded the project I'm working on to Filament V3 (and subsequently your package to v1.6.1). Changing the file permissions produces no result, and the files that are being looked for (though when I looked at them it looks like they're being created as empty)

Here is a minimal example of a spreadsheet which produced this error when I tried to import it

image

Do you have any idea what's causing this?

Thanks

Failed to load resource: the server responded with a status of 401 ()

I have a deploy in railway, when I try to upload a file I ge this error: Failed to load resource: the server responded with a status of 401 ()

https://************.up.railway.app/livewire/upload-file?expires=1684804246&signature=ba824fc87756de931adf57405a9897a978033a0b58ef1b315acd27022bb8a15b

in local works well.

any idea?

Handle JSON DB column

I installed the package and try to import to a JSON field (translated content) and I get "Illegal offset type" at line 62 in Konnco \ FilamentImport \ Actions \ ImportAction. Below the code :

$fieldsToImport = [];
       foreach (auth()->user()->company->languages as $language) {
           $fieldsToImport[] = ImportField::make('name.' . $language)
               ->label(__('Name') . ' (' . __('locales.' . $language) . ')')
               ->required()
               ->helperText(__('Select the name in the local'));
       }
       return [
           ImportAction::make()
               ->fields($fieldsToImport)
       ];

Discussions Page

Hi there, I want to ask a question and discuss a feature that I can help you with.
Can you set up the discussion feature in this repository?

Thanks.

'Konnco\FilamentImport\ImportField' is depreciated

Intelephense is saying that the ImportField is depreciated. It is still working but it is kind of annoying to have a line crossing through the word because I can't even see the word. Is it a bug? Or is Intelephense just not recognizing it? because it wasn't showing it was depreciated earlier today.. If nothing is depreciated, how do you suggest I remove the line? Thanks!

Persistent filetype validation error message

Whenever I upload any csv and xlsx and map the columns then click Submit, it always shows this message

The must be a file of type: application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/csv, text/plain, csv, txt.

Maximum execution time error

Could anyone advise on how I can resolve the following:

[2023-01-06 00:43:53] local.ERROR: Maximum execution time of 30 seconds exceeded {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Maximum execution time of 30 seconds exceeded at /Users/faruk/Development/Projects/elections-results/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php:166)
[stacktrace]
#0 {main}
"} 

Excel Blank Rows Calls mutateBeforeCreate

Hey!
First off - great package! It's saved us a lot of upfront time when importing excel spreadsheets.

We have began to notice an issue when a spreadsheet is modified and it introduced blank rows (as in the Excel Special Blank Rows). These 'Blank Rows' cause the mutateBeforeCreate logic etc to be called as they don't get filtered out before hand.

I have a fix for this which I'll fork and PR and I'll put my reasons for the implementation on there - just creating this issue for visibility in case it helps others.

Auto match columns

Discussed in #36

Originally posted by Frameck October 5, 2022
It would be nice to add the ability to choose whether the import should automatically match the columns to the values, because if you have a lot of columns it takes a long time to manually associate them each time.
So if Auto match columns is true the form with selects doesn't appear and it matches automatically based on the name of the columns.

Something like this:

Schermata 2022-10-05 alle 12 39 10

ImportAction for Filament\Tables\Actions\Action

I have a resource that has a relation manager associated, and I would like to be able to import data to the relation but when I add the import action it gives me an error saying Method Konnco\FilamentImport\Actions\ImportAction::table does not exist..

After investigating I noticed that the ImportAction extends Filament\Pages\Actions\Action and to be able to add an action to a tables headerActions param it has to extend Filament\Tables\Actions\Action. Could it be possible to create another ImportAction that extends the tables class so it can be usable inside relations and other places that can only be extended from Filament\Tables\Actions\Action?

Upload saves the values as array keys

Installed the packages and works great just cannot get the uploaded item to save the values, seems like it saves the array keys to the database. not sure if Im doing something wrong.

ImportAction::make()
    ->fields([
        ImportField::make('title')
            ->label('Title')
            ->mutateBeforeCreate(fn($string) => Str::lower($string)),
        ImportField::make('slug')
            ->label('Slug')
            ->mutateBeforeCreate(fn($string) => Str::upper($string)),
        ImportField::make('body')
            ->label('Body')
            ->mutateBeforeCreate(fn($string) => Str::upper($string)),
    ], columns:2)

Screenshot 2022-09-12 at 10 01 04

Uploaded csv

Screenshot 2022-09-12 at 10 02 08

Sync lock and json to update PSR/Simple-Cache dependancy lock

While issuing

composer require konnco/filament-import

I received this message

Problem 1
    - Root composer.json requires konnco/filament-import ^1.4 -> satisfiable by konnco/filament-import[1.4.0].
    - konnco/filament-import 1.4.0 requires psr/simple-cache ^2.0 -> found psr/simple-cache[2.0.0, 2.x-dev] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require konnco/filament-import:*" to figure out if any version is installable, or "composer require konnco/filament-import:^2.1" if you know which you need.

composer-lock-and-json.zip

importer does not convert expressions to values

If a cell has a value of any number that generate by an expression like this =RANDBETWEEN(100,500) or =B10+10 then the value it catch is =RANDBETWEEN(100,500) not the actual number. I tried casting values to int yet the same result :(

Import failed, please check your import file and try again

Import failed, please check your import file and try again

Hello everyone!

When I import latest excel file (data.xlsx) occured this error

How I fix this error please help me brothers

image

full_name // not working
phone // not working
client_id // not working
message // working

Import only read one row

Issue description

After updating to 1.0.2, I try to test the import feature and found only one row was inserted in the database.

Steps to reproduce the issue

The issue in the file src/Import.php at execute() function.

DB::transaction(function () {
    foreach ($this->getSpreadsheetData() as $row) {
        $prepareInsert = [];

        foreach ($this->fields as $key => $value) {
            $prepareInsert[$key] = $this->formSchemas[$key]?->doMutateBeforeCreate($row[$value]) ?? $row[$value];
        }

        if ($this->massCreate) {
            $this->model::create($prepareInsert);

            return;
        }

        $model = new $this->model;
        $model->fill($prepareInsert);
        $model->save();
    }
});

I figure out the issue in this section

if ($this->massCreate) {
    $this->model::create($prepareInsert);

    return;
}

If the massCreate is equal to true it will run code inside the block, and the problem is you return; the function, which makes the loop break and not continues to the next row in the file.

What's the expected result?

I expect to import all rows in excel or csv.

What's the actual result?

The package just imports only one row from file excel or csv.

Additional details / screenshot

importfile.csv
image

match data to column
image

the result
image

Importing only process one row

Hi ! 🖖

After using this plugin, I face a problem.

I need to import data and assign it to a belongsToMany relation, but on importing my xlsx file, only one row is processed:

This is my xlsx file:
image

This is the form:
image

N° volontaire = volunteer_id

And for each row I need to attach it on my pivot table like so:

cohort_id volunteer_id
1 6
1 7
1 8

But on import he create same cohorts with only one volunteer in it:

image
image

This is the code I use:

protected function getActions(): array
    {
        return [
            ImportAction::make()
                ->label('Importer une cohorte')
                ->fields([
                    TextInput::make('name')
                        ->required()
                        ->label('Nom de la cohorte'),

                    TextInput::make('description')
                        ->required()
                        ->label('Description de la cohorte'),

                    ImportField::make('volunteer_id')
                        ->label('Colonne N° de volontaire'),
                ])->mutateAfterCreate(function (Model $model, $row) {
                    $volunteer_id = $row['volunteer_id'];
                    Volunteer::find($volunteer_id)->cohorts()->save($model);
                }),
        ];
    }

Did I miss something in the doc ? Or it is a normal behavior ?

Thanks for reading,

Best regards !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.