PHP code example of one2tek / larasheets

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

    

one2tek / larasheets example snippets




use one2tek\larasheets\Services\LarasheetsService;

class GoogleSheetService
{
    private $larasheetsService;

    public function __construct()
    {
        $spreadsheetId = 'spreadsheet-id-from-console';
        $sheetName = 'sheet-name-from-console';
        $headers = ['Column1', 'Column2', 'Column3'];

        $this->larasheetsService = new LarasheetsService($spreadsheetId, $sheetName, $headers);
    }

    public function getAll()
    {
        return $this->larasheetsService->getAll();
    }

    public function getByLine($line)
    {
        return $this->larasheetsService->getByLine($line);
    }

    public function update($line, $data)
    {
        $data = [$data['column1'], $data['column2'], $data['column3']];
        
        return $this->larasheetsService->updateByLine($line, $data);
    }

    public function create($data)
    {
        $data = [$data['column1'], $data['column2'], $data['column3']];
       
        return $this->larasheetsService->create($data);
    }
}

laravel_cache' => [
    'enable' => true,
    'driver' => 'file',
    'remember_forever' => false,
    'remember_in_seconds' => 600 // 10 minutes
]