PHP code example of rtmatt / csvimport

1. Go to this page and download the library: Download rtmatt/csvimport 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/ */

    

rtmatt / csvimport example snippets

  php
//...
RTMatt\CSVImport\Providers\CSVImportServiceProvider::class,
//...
App\Providers\RouteServiceProvider::class,
 bash
$ php artisan vendor:publish --provider="RTMatt\CSVImport\Providers\CSVImportServiceProvider"
 bash
$ php artisan csvimport:make Users

AffiliatesImporter.php
UsersImporter.php
UserPhotosImporter.php
 php
	'import_order'=>[
		'user_photos'=>0
		'affiliates'=>1
	],
 php
	public function can_import()
    {
        // your permission logic here
        // return true|false
    }
 php
'sql_directory'=>'/home/users/jondoe/sql_store',
 php
'importer_directory'=>app_path('IWantMyImportersHereForReasons'),
'importer_namespace'=>"\\App\\IWantMyImportersHereForReasons\\",
 php
	Route::controller([your preferred route here],'\RTMatt\CSVImport\CSVImportController');
 php
protected function overrideImportCommand()
{
	$statement = "[...]";//Your sql statement 
	return $statement;
}
 php
protected function postSQLImport()
{
	// post import logic here
}
 php
protected function postSQLImport()
{
	$users = \App\User::all();
	foreach($users as $user){
		$user->full_name = $user->first_name.' '.$user->last_name;
		$user->save;
	}
}
 bash
$ php artisan route:clear