naifalshaye / nova-push-notifications

A Laravel Nova tool to send push notifications. Currently supporting just via OneSignal
16 stars 3 forks source link

Suggestion: default params in config #5

Open rtrudel opened 4 years ago

rtrudel commented 4 years ago

Very nice tool!

If I may suggest something, why not having ability to add default parameters (globally)? Those can easily merged to $data

Ex:

<?php
return [
    'app_id' => env('PUSH_APP_ID'),
    'api_key' => env('PUSH_API_KEY'),
    'params' => [
        'priority' => 10,
        'android_accent_color' => 'FF3578bc',
        'android_led_color' => 'FF3578bc',
    ]
];

In PushNotificationController.php:

...

if ( ! empty($request->url)) {
    $data['url'] = $request->url;
}

// Maybe something like this?
$data = array_merge($data, config('push_notifications.params'));

$response = $oneSignalApi->notifications->add($data);

(I know I can also fork and add it myself...)