mkohei/laravel-google-sheets-notification-channel

Laravel的Google Sheets通知通道

v1.0.0 2022-03-31 06:52 UTC

This package is auto-updated.

Last update: 2024-09-29 06:09:06 UTC


README

tests StyleCI

此包通过Laravel通知系统和Google Sheets API,简化了使用Google Sheets的操作。

内容

安装

您可以通过composer安装此包

composer require mkohei/laravel-google-sheets-notification-channel

将Google App客户端ID和客户端密钥设置到config/services.php

'google' => [
    'sheets' => [
        'client_id' => env('INTEGRATIONS_GOOGLE_SHEETS_CLIENT_ID'),
        'client_secret' => env('INTEGRATIONS_GOOGLE_SHEETS_CLIENT_SECRET'),
    ],
],

config/app.php中添加服务提供者

/*
 * Package Service Providers...
 */
Mkohei\LaravelGoogleSheetsNotificationChannel\GoogleSheetsServiceProvider::class,

使用

现在您可以在通知的via()方法中使用此通道

use Mkohei\LaravelGoogleSheetsNotificationChannel\GoogleSheetsChannel;
use Mkohei\LaravelGoogleSheetsNotificationChannel\GoogleSheetsMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    public function via($notifiable)
    {
        return [GoogleSheetsChannel::class];
    }

    public function toGoogleSheets($notifiable)
    {
        return TreasureDataMessage::create()
            ->data(['value1', 'value2'])
            ->accessToken('your-access-token')
            ->spreadsheetId('id');
    }
}

测试

composer test

许可证

MIT许可证.