Last active
December 16, 2021 12:02
-
-
Save najathi/0bc8fb7fe87c75023f764c2ef4d42742 to your computer and use it in GitHub Desktop.
Add New sheet and data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function addOrderProperty() | |
{ | |
$sheets = Sheets::spreadsheet(config('sheets.post_spreadsheet_id'))->sheetList(); | |
$now = now()->year . '/' . now()->month; | |
$id = Arr::get(array_flip($sheets), $now); | |
if (is_null($id)) { | |
$body = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array( | |
'requests' => array( | |
'addSheet' => array( | |
'properties' => array( | |
'title' => $now | |
) | |
) | |
) | |
)); | |
Sheets::getService()->spreadsheets->batchUpdate(config('sheets.post_spreadsheet_id'), $body); | |
Sheets::spreadsheet(config('sheets.post_spreadsheet_id')) | |
->sheet($now) | |
->append([['SOURCE', 'USER/NAME', 'DEVICE', 'Date Of Arrival', 'Date Of Dispatch', 'Post Code', 'NOTE', 'Label', 'CANCELLED']]); | |
} | |
Sheets::spreadsheet(config('sheets.post_spreadsheet_id')) | |
->sheet($now) | |
->append([['BBC', 'ORRRR111', 'SAMPLE', '2/10', '03/13', 'RH1 111', '-', 'L', '']]); | |
return ['success']; | |
} | |
public function getOrdersProperty() | |
{ | |
$sheets = Sheets::spreadsheet(config('sheets.post_spreadsheet_id')) | |
->sheet('Sheet1') | |
->get(); | |
$header = $sheets->pull(0); | |
$values = Sheets::collection($header, $sheets); | |
return $values->reverse(); | |
// Blade | |
// @foreach($values as $value) | |
// {{ data_get($value, 'name') }} | |
// @endforeach | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment