You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+156-11
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,33 @@
1
-
2
-
# A livewire CSV Importer, to handle importing millions of rows
3
-
4
-
[](https://packagist.org/packages/coderflexx/laravel-csv)
[](https://packagist.org/packages/coderflexx/laravel-csv)
__Laravel CSV__ Package is a package created on top of Laravel [livewire](https://laravel-livewire.com) package, and it handles importing thousands of records without any issues.
8
31
9
32
## Installation
10
33
@@ -14,34 +37,153 @@ You can install the package via composer:
| This package came with file validation for uploaded files,
80
+
| and by default the file should not be greater than 20MB. If
81
+
| you wish to increase/decrease this value, you may change the
82
+
| value below.
83
+
| Note that the value is defined by "KB".
84
+
|
85
+
*/
86
+
'file_upload_size' => 20000,
34
87
];
35
88
```
36
89
90
+
The `layout` option is for choosing which CSS Framework you are using, currently supports only `tailwindcss`, and we're working on other CSS frameworks to implement in the future.
91
+
92
+
The `file_upload_size` is for validation rules, and it helps define the file size of the uploaded files, or. You can define this one from [livewire config](https://github.com/livewire/livewire/blob/master/config/livewire.php#L100) file.
| model |`string`| Fully qualified name of the model wants to import to |
122
+
| columns-to-map |`array`| Accept Columns need to be imported in the db |
123
+
| required-columns |`array`| Accept Columns need to be required while importing |
124
+
| columns-label |`array`| Accept Column Label of the required columns for the message |
125
+
126
+
### Button Component
127
+
The Component using `alpinejs` under the hood, If you want to use add the import button, you may use `x-csv-button` component.
128
+
129
+
```blade
130
+
<x-csv-button>Import</x-csv-button>
131
+
```
132
+
133
+
If you want to style it, you can use the `class` attribute, or any attribute you want really
134
+
135
+
```blade
136
+
<x-csv-button
137
+
class="rounded py-2 px-3 bg-indigo-500 ..."
138
+
type="button"
139
+
....>
140
+
{{ __('Import') }}
141
+
</x-csv-button>
142
+
```
143
+
### In TALL stack project
144
+
If you are using this package in a [TALL Stack]() project, (Tailwindcss, Alpinejs, Laravel, Livewire) All what you need to do is publish the vendor views
145
+
146
+
```bash
147
+
php artisan vendor:publish --tag="csv-views"
148
+
```
149
+
Then compile your assets, to add the additional classes, came with the component.
150
+
```bash
151
+
npm run dev
152
+
```
153
+
154
+
### In none TALL Stack project
155
+
If you are not using the TALL Stack by default, you may use the `csv directives` to add the necessary styles/scripts
156
+
157
+
```blade
158
+
<html>
159
+
...
160
+
<head>
161
+
...
162
+
@csvStyles
163
+
</head>
164
+
...
165
+
<footer>
166
+
...
167
+
@csvScripts
168
+
</footer>
169
+
</html>
170
+
171
+
```
172
+
### Using Queues
173
+
This package is using [queues](https://laravel.com/docs/9.x/queues#main-content), under the hood with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php), to make it works fast and efficient.
174
+
175
+
You need first to create the `batches table`
176
+
```bash
177
+
php artisan queue:batches-table
178
+
```
179
+
Then run the migration
180
+
```
181
+
php artisan migrate
182
+
```
183
+
184
+
After that, you need to set up the queues' configuration.
185
+
You may head into [Laravel Queues Documentation](https://laravel.com/docs/9.x/queues#main-content) to learn more.
186
+
45
187
46
188
## Testing
47
189
@@ -61,6 +203,9 @@ Please see [CONTRIBUTING](https://github.com/ousid/.github/blob/main/CONTRIBUTIN
61
203
62
204
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
63
205
206
+
## Inspiration
207
+
This Package Was Inspired by [codecourse](https://codecourse.com), and if you learn how this package created, make sure to take a look at this [video series](https://codecourse.com/subjects/laravel-livewire)
0 commit comments