1. Go to this page and download the library: Download askdkc/livewire-csv 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/ */
askdkc / livewire-csv example snippets
namespace App\Models;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Askdkc\LivewireCsv\Concerns\HasCsvImports; // add
...
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasCsvImports; // add HasCsvImports here
> $table->unique(['name', 'email']);
>
> // $table->id(); You need to remove or comment out this line because you cannot have multiple primary keys
> $table->string('email')->primary();
>
return [
/*
|--------------------------------------------------------------------------
| Default Layout
|--------------------------------------------------------------------------
|
| This package plans on supporting multiple CSS frameworks.
| Currently, 'tailwindcss' is the default and only supported framework.
|
*/
'layout' => 'tailwindcss',
/*
|--------------------------------------------------------------------------
| Default File Type
|--------------------------------------------------------------------------
|
| If you change file_type to tsv, it can handle tsv files.
|
*/
'file_type' => 'csv',
/*
|--------------------------------------------------------------------------
| Default Set Delimiter
|--------------------------------------------------------------------------
|
| If you change Set Delimiter to file.
|
*/
'set_delimiter' => ',',
/*
|--------------------------------------------------------------------------
| Max Upload File Size
|--------------------------------------------------------------------------
|
| The default maximumum file size that can be imported by this
| package is 100MB. If you wish to increase/decrease this value,
| change the value in KB below.
|
*/
'file_upload_size' => 102400,
];