PHP code example of askdkc / livewire-csv

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,
];
bash
php artisan livecsv-setup
bash
php artisan vendor:publish --tag="livewire-csv-migrations"
php artisan migrate
bash
php artisan queue:table
php artisan queue:batches-table
php artisan migrate
bash
php artisan vendor:publish --tag="livewire-csv-config"
bash
php artisan vendor:publish --tag="livewire-csv-views"
bash
php artisan vendor:publish --tag="csv-views"
bash
php artisan queue:batches-table

php artisan migrate