My Blog Posts

Using Google Excel with Eloquent Queries

Using Google Excel with Eloquent Queries

Eloquent Spreadsheets is a package by Ed Grosvenor that allows you to work through Google Spreadsheets and Eloquent models:

This package provides an Eloquent model located on top of a Google Excel. There are two things your page must have to have to work on. One is a row of headings that hold the name of your columns. By default, this comes to line 1 (top row), but there may be any line on the page. The other is the primary key column. Eloquent assumes that your primary key column is named id. If not, adjust your model by columns in excel.

When we do the model class you create, it looks like the following example:

use Grosv\EloquentSheets\SheetModel;class YourGoogleSheetsModel extends SheetModel
// The id of the spreadsheet
protected $spreadsheetId = '1HxNqqLtc614UVLoTLEItfvcdcOm3URBEM2Zkr36Z1rE';
// The id of the sheet within the spreadsheet (gid=xxxxx on the URL)
protected $sheetId = '0';
// The row containing the names of your columns (eg. id, name, email, phone)
protected $headerRow = '1';

You can use effective features with the Google Excel model; however, the model can currently only use reading and listing methods. Updating and adding does not work, but this package provides a way to read page data through Eloquent. New versions can add add and update features.

If you would like to learn more about this package, see GitHub at grosv/ eloquent-sheets.

Share this article

Comments (0)