mkohei / laravel-google-sheets-notification-channel
Laravel的Google Sheets通知通道
v1.0.0
2022-03-31 06:52 UTC
Requires
- php: ^8.0
Requires (Dev)
- google/apiclient: ^2.12
- guzzlehttp/guzzle: ^7.4
- illuminate/notifications: ^9.5
- mockery/mockery: ^1.5
- pestphp/pest: ^1.21
README
此包通过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