定制 aigorlaxy/google-sheets-model-importer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aigorlaxy/google-sheets-model-importer

最新稳定版本:13

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

Latest Version on Packagist Total Downloads

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

  1. Create a Google Spreadsheet.

  2. Publish it to internet and set general access to anyone with the link can be a viewer.

  3. Include the trait in your model class.

  4. $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

  5. $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

  6. $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.

  7. $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.

  8. 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.
}
  1. Any issue or suggestions, please send me an e-mail: igor1523@gmail.com

统计信息

  • 总下载量: 3.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固