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


$googleSheetModelImpoter = new GoogleSheetModelImpter(Model $model, string $googleSpreadSheetId, string $googleSheetId);

  $googleSheetModelImpoter->updateColumnIndex = 'your_column_name';
  

  $googleSheetModelImpoter->colunsToSkip = 'your_column_in_google_sheets_to_skip';
  

$model = User::class;
$googleSpreadSheetId = '1gaLFuSnh20kggxEaasr511s15vt3olKqp9o12HenDLI3vA7pg';
$sheetId = '15144122';
$googleSheetModelImpoter = new GoogleSheetModelImpter($model, $googleSpreadSheetId, $googleSheetId);

$googleSheetModelImpoter->updateOrCreate(); // Updating and inserting new data.
$googleSheetModelImpoter->getFreshTable(); // Truncate the current table and inserting the new data.