Skip to content

Commit a95f4cf

Browse files
committed
update README.md
1 parent c3da85a commit a95f4cf

File tree

3 files changed

+160
-15
lines changed

3 files changed

+160
-15
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
4-
url: https://github.com/Coderflex/laravel-csv/discussions/new?category=q-a
4+
url: https://github.com/Coderflexx/laravel-csv/discussions/new?category=q-a
55
about: Ask the community for help
66
- name: Request a feature
7-
url: https://github.com/Coderflex/laravel-csv/discussions/new?category=ideas
7+
url: https://github.com/Coderflexx/laravel-csv/discussions/new?category=ideas
88
about: Share ideas for new features
99
- name: Report a security issue
10-
url: https://github.com/Coderflex/laravel-csv/security/policy
10+
url: https://github.com/Coderflexx/laravel-csv/security/policy
1111
about: Learn how to notify us for sensitive bugs
1212
- name: Report a bug
13-
url: https://github.com/Coderflex/laravel-csv/issues/new
13+
url: https://github.com/Coderflexx/laravel-csv/issues/new
1414
about: Report a reproducable bug

README.md

Lines changed: 156 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1-
2-
# A livewire CSV Importer, to handle importing millions of rows
3-
4-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/coderflex/laravel-csv.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-csv)
5-
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/coderflex/laravel-csv/run-tests?label=tests)](https://github.com/coderflexx/laravel-csv/actions?query=workflow%3Arun-tests+branch%3Amain)
6-
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/coderflex/laravel-csv/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/coderflexx/laravel-csv/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
7-
[![Total Downloads](https://img.shields.io/packagist/dt/coderflex/laravel-csv.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-csv)
1+
<p align="center">
2+
<img src="art/logo.png" alt="Laravisit Logo" width="300">
3+
<br><br>
4+
</p>
5+
6+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/coderflexx/laravel-csv.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-csv)
7+
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/coderflexx/laravel-csv/run-tests?label=tests)](https://github.com/coderflexx/laravel-csv/actions?query=workflow%3Arun-tests+branch%3Amain)
8+
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/coderflexx/laravel-csv/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/coderflexx/laravel-csv/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
9+
[![Total Downloads](https://img.shields.io/packagist/dt/coderflexx/laravel-csv.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-csv)
10+
11+
12+
- [Introduction](#introduction)
13+
- [Installation](#installation)
14+
- [Configuration](#configuration)
15+
- [Usage](#usage)
16+
- [CSV Importer Component](#csv-importer-component)
17+
- [Button Component](#button-component)
18+
- [In TALL stack project](#in-tall-stack-project)
19+
- [In none TALL Stack project](#in-none-tall-stack-project)
20+
- [Using Queues](#using-queues)
21+
- [Testing](#testing)
22+
- [Changelog](#changelog)
23+
- [Contributing](#contributing)
24+
- [Security Vulnerabilities](#security-vulnerabilities)
25+
- [Inspiration](#inspiration)
26+
- [Credits](#credits)
27+
- [License](#license)
28+
29+
## Introduction
30+
__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.
831

932
## Installation
1033

@@ -14,34 +37,153 @@ You can install the package via composer:
1437
composer require coderflex/laravel-csv
1538
```
1639

40+
## Configuration
41+
1742
You can publish and run the migrations with:
1843

1944
```bash
20-
php artisan vendor:publish --tag="laravel-csv-migrations"
45+
php artisan vendor:publish --tag="csv-migrations"
2146
php artisan migrate
2247
```
2348

2449
You can publish the config file with:
2550

2651
```bash
27-
php artisan vendor:publish --tag="laravel-csv-config"
52+
php artisan vendor:publish --tag="csv-config"
2853
```
2954

3055
This is the contents of the published config file:
3156

3257
```php
58+
3359
return [
60+
61+
/*
62+
|--------------------------------------------------------------------------
63+
| Default Layout
64+
|--------------------------------------------------------------------------
65+
|
66+
| This package came with multiple layouts to serve your need, and
67+
| currently it supports "tailwindcss" and "bootstrap", by default
68+
| the layout is tailwind.
69+
| currently support: "tailwindcss", "bootstrap"
70+
|
71+
*/
72+
'layout' => 'tailwindcss',
73+
74+
/*
75+
|--------------------------------------------------------------------------
76+
| Max Upload File Size
77+
|--------------------------------------------------------------------------
78+
|
79+
| 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,
3487
];
3588
```
3689

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.
93+
3794
Optionally, you can publish the views using
3895

3996
```bash
40-
php artisan vendor:publish --tag="laravel-csv-views"
97+
php artisan vendor:publish --tag="csv-views"
4198
```
4299

100+
> Before Using this command, please take a look at this [section]() below.
101+
43102
## Usage
44-
...
103+
104+
### CSV Importer Component
105+
Using this package, is really simple, all what you need to do is implementing the component inside your desired file.
106+
107+
```blade
108+
<livewire:csv-importer :model="App\Models\YourModel::class"
109+
:columns-to-map="['id', 'name', 'email', 'password']"
110+
:required-columns="['id', 'name', 'email']"
111+
:columns-label="[
112+
'id' => 'ID',
113+
'name' => 'Name',
114+
'email' => 'Email Address',
115+
'password' => 'Password',
116+
]"/>
117+
```
118+
119+
| Props | Type | Description |
120+
|---|---|---|
121+
| 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+
45187

46188
## Testing
47189

@@ -61,6 +203,9 @@ Please see [CONTRIBUTING](https://github.com/ousid/.github/blob/main/CONTRIBUTIN
61203

62204
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
63205

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)
208+
64209
## Credits
65210

66211
- [ousid](https://github.com/ousid)

art/logo.png

110 KB
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy