PHPackages                             grosv/eloquent-sheets - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. grosv/eloquent-sheets

ActiveLibrary[Database &amp; ORM](/categories/database)

grosv/eloquent-sheets
=====================

Eloquent models backed by Google Sheets

1.2.3(5y ago)2904.4k↓100%16[3 issues](https://github.com/grosv/eloquent-sheets/issues)[1 PRs](https://github.com/grosv/eloquent-sheets/pulls)MITPHPPHP ^7.3

Since Mar 3Pushed 5y ago10 watchersCompare

[ Source](https://github.com/grosv/eloquent-sheets)[ Packagist](https://packagist.org/packages/grosv/eloquent-sheets)[ RSS](/packages/grosv-eloquent-sheets/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (5)Versions (8)Used By (0)

Eloquent Models for your Google Sheets
======================================

[](#eloquent-models-for-your-google-sheets)

### A package that lets you lay Eloquent on top of a Google Sheet.

[](#a-package-that-lets-you-lay-eloquent-on-top-of-a-google-sheet)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6a7d820852cc0b534bb0af350b747f4070ed4dc53c8fee9508f3146a30668db4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67726f73762f656c6f7175656e742d7368656574732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grosv/eloquent-sheets)[![StyleCI](https://camo.githubusercontent.com/9252b679a1f1f0bb3f85b839034e6f9461ca3c831a56b7c99161b1cdd05ad7c2/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3234343338363530352f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/244386505)[![Build Status](https://camo.githubusercontent.com/e3e03cdc99e185585a73c615f62bee5d763ef4b50df3a70e7f95253233d5965f/68747470733a2f2f6170702e6368697070657263692e636f6d2f70726f6a656374732f36356438386533642d656366342d346365642d616664332d6535626133353933636532312f7374617475732f6d6173746572)](https://camo.githubusercontent.com/e3e03cdc99e185585a73c615f62bee5d763ef4b50df3a70e7f95253233d5965f/68747470733a2f2f6170702e6368697070657263692e636f6d2f70726f6a656374732f36356438386533642d656366342d346365642d616664332d6535626133353933636532312f7374617475732f6d6173746572)

This package provides an Eloquent model that sits on top of a Google Sheet. You can use a heading row that holds the name of your columns. This defaults to row 1 (the top row) but it can be any row in the sheet. Or you can define an array of headings in your model. If you choose not to have a primary key column in your spreadsheet, each column will get an id (or whatever you're calling your primary key column in your model) auto-incremented.

When you use this package, an initial invocation of the model will read the sheet and store each row as a record in a table inside a file-based sqlite database. Subsequent invocations of the model use that sqlite database so changes to the spreadsheet won't be reflected in the database. However, there are two ways that you can invalidate the sqlite cache and cause it to be recreated:

1. You can call the invalidateCache() method on the model with something like like `YourGoogleSheetModel::first()->invalidateCache()`
2. A macro that you can attach to your Google sheet. The macro listens for edits within the sheet and when one happens, it sends a request to a route provided by this package that deletes the sqlite database forcing a fresh load the next time the model is used.

### Installation

[](#installation)

```
composer require grosv/eloquent-sheets
```

### Configuration

[](#configuration)

This package relies on [revolution/laravel-google-sheets](https://github.com/kawax/laravel-google-sheets). You must handle the configuration for that package and its dependencies for this package to work. Follow the instructions in their readme (though you can skip the composer require bit because I do that already in here).

### Usage

[](#usage)

Consider the following Google Sheet. We want to lay an Eloquent model on top of it.

[![Screen Shot 2020-03-03 at 3 02 15 PM](https://user-images.githubusercontent.com/1053395/75819454-5440d500-5d60-11ea-8f5b-0e4e04a39326.png)](https://user-images.githubusercontent.com/1053395/75819454-5440d500-5d60-11ea-8f5b-0e4e04a39326.png)

```
php artisan make:sheet-model
```

**Step 1 - Enter the full path to the directory where you want to create the model file (defaults to app\_path()):**

[![Screen Shot 2020-03-11 at 4 48 48 PM](https://user-images.githubusercontent.com/1053395/76467708-373b8000-63b8-11ea-8cfc-e8f7ee084559.png)](https://user-images.githubusercontent.com/1053395/76467708-373b8000-63b8-11ea-8cfc-e8f7ee084559.png)

---

**Step 2 - Enter the name you want to use for your model class:**

[![Screen Shot 2020-03-03 at 3 11 10 PM](https://user-images.githubusercontent.com/1053395/75820030-3de74900-5d61-11ea-9cf2-84d2c6977cbb.png)](https://user-images.githubusercontent.com/1053395/75820030-3de74900-5d61-11ea-9cf2-84d2c6977cbb.png)

---

**Step 3 - Paste the edit url of your Google Sheet from the browser address bar:**

[![Screen Shot 2020-03-03 at 3 13 33 PM](https://user-images.githubusercontent.com/1053395/75820229-99b1d200-5d61-11ea-9d18-37372b108976.png)](https://user-images.githubusercontent.com/1053395/75820229-99b1d200-5d61-11ea-9d18-37372b108976.png)

---

**Step 4 - Confirm that the path and full classname look right:**

[![Screen Shot 2020-03-03 at 3 14 47 PM](https://user-images.githubusercontent.com/1053395/75820325-c4038f80-5d61-11ea-987d-edac8e820caf.png)](https://user-images.githubusercontent.com/1053395/75820325-c4038f80-5d61-11ea-987d-edac8e820caf.png)

---

**Step 5 - And you will receive the template of a macro that you can attach to your sheet that will tell your site that the sheet has changed so a new cache has to be built.**

[![Screen Shot 2020-03-03 at 3 20 58 PM](https://user-images.githubusercontent.com/1053395/75820796-a256d800-5d62-11ea-8cff-2b5c0d42efb3.png)](https://user-images.githubusercontent.com/1053395/75820796-a256d800-5d62-11ea-8cff-2b5c0d42efb3.png)

---

You can use something like this to enable the macro generated on your sheet as an [installable trigger](https://developers.google.com/apps-script/guides/triggers/installable):

```
function createSpreadsheetOpenTrigger() {
  var ss = SpreadsheetApp.getActive();
  ScriptApp.newTrigger('onEdit')
      .forSpreadsheet(ss)
      .onEdit()
      .create();
}
```

### The Resulting Model Class

[](#the-resulting-model-class)

```
use Grosv\EloquentSheets\SheetModel;

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

This model can do your basic Eloquent model stuff because it really is an Eloquent model. Though it's currently limited to read / list methods. Update and insert don't currently work because you do those things by editing your spreadsheet.

### What's Missing

[](#whats-missing)

Eventually I'd like to add insert and update methods that will let you append rows to your spreadsheet and edit existing rows. I already have the most important part done... a method to invalidate the cache when we update or insert. Now I just need the update and insert methods.

### Acknowledgements

[](#acknowledgements)

This package wouldn't be possible without [Sushi](https://github.com/calebporzio/sushi) by Caleb Porzio. If you're not [sponsoring him on GitHub](https://github.com/sponsors/calebporzio) you should.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~41 days

Total

7

Last Release

2070d ago

Major Versions

0.1 → 1.0.02020-03-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/55eed7400c452edf7e7adfa4f1c6676b65b5ce1867fff6bddcb80b1bb45360af?d=identicon)[edgrosvenor](/maintainers/edgrosvenor)

---

Top Contributors

[![edgrosvenor](https://avatars.githubusercontent.com/u/1053395?v=4)](https://github.com/edgrosvenor "edgrosvenor (35 commits)")[![fredericseiler](https://avatars.githubusercontent.com/u/954168?v=4)](https://github.com/fredericseiler "fredericseiler (2 commits)")[![josecanhelp](https://avatars.githubusercontent.com/u/2329654?v=4)](https://github.com/josecanhelp "josecanhelp (1 commits)")[![tabuna](https://avatars.githubusercontent.com/u/5102591?v=4)](https://github.com/tabuna "tabuna (1 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/grosv-eloquent-sheets/health.svg)

```
[![Health](https://phpackages.com/badges/grosv-eloquent-sheets/health.svg)](https://phpackages.com/packages/grosv-eloquent-sheets)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
