PHP code example of aigorlaxy / google-sheets-model-importer

1. Go to this page and download the library: Download aigorlaxy/google-sheets-model-importer 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/ */

    

aigorlaxy / google-sheets-model-importer example snippets


use Aigorlaxy\GoogleSheetsModelImporter\GoogleSheetsModelImporterTrait;

class YourModel extends Model
{
    use GoogleSheetsModelImporterTrait;
}

protected string $googleSpreadSheetId = 'your_google_spreadsheet_id';

protected string|array $googleSheetId = 'your_google_sheet_id'; // or ['sheet1_gid', 'sheet2_gid']


protected string $updateColumnIndex = 'your_column_index';


protected string|array $columnsToSkip = 'column_1'; // or ['column_1', 'column_2']


$model = new YourModel();
$model->updateOrCreateFromGoogleSheets(); // Updating and inserting new data.
$model->getFreshTableFromGoogleSheets(); // Truncating the current table and inserting the new data.