Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/w99910/laravel-google-sheet
Laravel Google Sheet Service
https://github.com/w99910/laravel-google-sheet
Last synced: 2 months ago
JSON representation
Laravel Google Sheet Service
- Host: GitHub
- URL: https://github.com/w99910/laravel-google-sheet
- Owner: w99910
- License: mit
- Created: 2022-01-12T07:53:04.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T04:18:59.000Z (6 months ago)
- Last Synced: 2024-09-19T15:50:11.044Z (4 months ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Google Sheet Service For Laravel
## Prerequisites
- PHP : `^7.4`
## Preparation
Insert the required credentials inside `config/filesystems.php` as follow.
```php
'google' => [
'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN')
],
```## General
- ### How to get **sheetId**
You can get the sheetId from the url.
For example, in the url **"https://docs.google.com/spreadsheets/d/1234567890/edit#gid=0"**,
the sheetId would be `1234567890`.## Available Methods
- **get($sheetId, $range='')**
Get all rows inside the sheet.
```php
$service = new Zlt\LaravelGoogleSheet\Services\GoogleSheetService();
dd($service->get('sheetId'));
// You can specify the range
dd($service->get('sheetId','A:G'))
```- **getValuesBySheetName($sheetId,$sheetName,$range='')**
Get all rows from specific sheet name.
```php
$service = new Zlt\LaravelGoogleSheet\Services\GoogleSheetService();
dd($service->getValuesBySheetName('sheetId','sheetName'));
```- **getSheetDetails($sheetId)**
Get details of sheet id.
```php
$service = new Zlt\LaravelGoogleSheet\Services\GoogleSheetService();
dd($service->getSheetDetails('sheetId'));
```- **insertValues($sheetId, $range, array $values, $valueInputOption = "RAW")**
Append new rows to sheet.
```php
$service = new Zlt\LaravelGoogleSheet\Services\GoogleSheetService();
dd($service->insertValues('sheetId','A:D',[[1,2,3,4],[a,b,c,d]]));
```- **getServiceInstance**
Get `Sheet` instance.
```php
$service = new Zlt\LaravelGoogleSheet\Services\GoogleSheetService();/** @var Google\Service\Sheets $sheetService */
$sheetService = $service->getServiceInstance();
```