aigorlaxy/google-sheets-model-importer
Composer 安装命令:
composer require aigorlaxy/google-sheets-model-importer
包简介
A simple trait to insert or update data to models from Google Sheets with just the link of the published spreadsheet. No need of Google API.
README 文档
README
A simple Laravel support trait to insert or update data to models from Google Sheets with just the link of the published spreadsheet. No need of Google API.
Installation
You can install the package via composer:
composer require aigorlaxy/google-sheets-model-importer
Using
-
Create a Google Spreadsheet.
-
Publish it to internet and set general access to anyone with the link can be a viewer.
-
Include the trait in your model class.
-
$spreadsheetId: is the id of your google sheets. You will use your published Google Sheets link to get it. The link will look something like that: https://docs.google.com/spreadsheets/d/e/YOU_GOOGLE_SHEET_SPREADSHEET_ID/something_else
-
$sheetIds: If you have just one tab for that model, use the gid as a string. If you have more than one tab for the same model, use array. All models must match the same column schema to work. The link will look something like that: https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?gid=YOUR_SHEET_ID
-
$updateColumnIndex: Optionaly you can set a different primary key to check for updates. if your primary key is not default id or you want to track updates based on another column. If not set, it will assume that id column is your primary key.
-
$colunsToSkip: You can also optionaly set columns to be skipped. The app will search for columns that contains any of that strings and will skip the import for that ones. You can set a single string or an array.
-
Example of usage:
use Illuminate\Database\Eloquent\Model; use Aigorlaxy\GoogleSheetsModelImporter\GoogleSheetsImportable; class YourModel extends Model { Use GoogleSheetsImportable; $model = User::class; $googleSpreadSheetId = '1gaLFuSnh20kggxEaasr511s15vt3olKqp9o12HenDLI3vA7pg'; $sheetId = '15144122'; $model::getFreshTableFromGoogleSheets($spreadsheetId, $sheetIds); // Truncate the current table and inserting the new data. $model::updateOrCreateFromGoogleSheets($spreadsheetId, $sheetIds); // Updating and inserting new data. }
- Any issue or suggestions, please send me an e-mail: igor1523@gmail.com
aigorlaxy/google-sheets-model-importer 适用场景与选型建议
aigorlaxy/google-sheets-model-importer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.05k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aigorlaxy/google-sheets-model-importer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aigorlaxy/google-sheets-model-importer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-08