konnco / filament-import Goto Github PK
View Code? Open in Web Editor NEWwhy import must use a template when you can import all files dynamically?
License: MIT License
why import must use a template when you can import all files dynamically?
License: MIT License
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?
I installed the package and tried to import an excel file into the database, and I got an error:
This is my environments:
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)
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
Do you have any idea what's causing this?
Thanks
If I import a date, I receive weird data instead of the date.
add a data validation to handle unique fields (columns) in the db.
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?
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)
];
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.
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!
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.
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}
"}
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.
the laravel.log file is filled with auto_detect_line_endings is deprecated ... vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php on line 318. PHP 8.1 is required for Laravel 10. How to suppress this warning? Here is the related bug reported on laravel-excel
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:
File [/home/u1694184/public_html/demo-sip-simakberita.com/storage/app/livewire-tmp/nhaUTQr5TnrrzFHbfk4T5SJ0yo5y9z-metaZm9ybWF0LXBlbWFpbi54bHN4-.xlsx] (local) does not exist and can therefor not be imported.
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
?
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)
Uploaded csv
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.
We need to check if the row is empty
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 :(
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, null given
update for filament 3.x
The Import Fields Not Detecting in The Latest Version . For Now I am using this -> dev-filament3#5f5019f128f497a6ea6464f94784c63fe0374a29
After updating to 1.0.2, I try to test the import feature and found only one row was inserted in the database.
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.
I expect to import all rows in excel or csv.
The package just imports only one row from file excel or csv.
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:
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:
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 !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.