mkohei/laravel-google-sheets-notification-channel

Google Sheets Notification Channel for Laravel

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

This package is auto-updated.

Last update: 2024-03-29 04:33:34 UTC


README

tests StyleCI

This package makes it easy to send Google Sheets using the Laravel notification system and the Google Sheets API.

Contents

Installation

You can install the package via composer:

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

Set your Google App Client ID and Client Secret to config/services.php:

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

Add a service provider to config/app.php:

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

Usage

Now you can use the channel in your via() method inside the notification:

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');
    }
}

Testing

composer test

License

MIT License.