jawabapp / cloud-messaging
1.1.10
2024-08-29 16:40 UTC
Requires
- google/apiclient: ^2.1
- google/cloud-bigquery: ^1.12
- guzzlehttp/guzzle: ^6.5
- nesbot/carbon: ^2.0
This package is auto-updated.
Last update: 2026-05-29 01:54:39 UTC
README
Installation
You can install the package via composer:
composer require jawabapp/cloud-messaging
Usage
User.php Model
use Jawabapp\CloudMessaging\Contracts\TargetAudience; use Jawabapp\CloudMessaging\Traits\EloquentGetTableNameTrait; use Jawabapp\CloudMessaging\Traits\HasTargetAudience; class User extends Authenticatable implements TargetAudience { use HasTargetAudience; use EloquentGetTableNameTrait; //... }
implement those methods from TargetAudience interface.
use Illuminate\Database\Eloquent\Builder; class User extends Authenticatable implements TargetAudience { public static function targetAudienceForPhoneNumbers(Builder $query, $phone_numbers) { //... } public static function targetAudienceForOS(Builder $query, $os) { //... } }
Adding more filters
User.php Model
public static function targetAudienceForCountries(Builder $query, $condition, $options, &$joins) { if ($condition === 'is_not_in') { $query->whereNotIn('phone_country', $options); } else { $query->whereIn('phone_country', $options); } }
cloud-messaging.php config file
'filter_types' => [ [ 'value' => 'countries', 'label' => 'Country/Region', 'selectLabel' => 'Countries', 'conditions' => [ [ 'value' => 'is_in', 'label' => 'Is in', ], [ 'value' => 'is_not_in', 'label' => 'Is not in', ] ] ], //... ]
web.php web route file
Route::group(['prefix' => env('JAWAB_CLOUD_MESSAGING_PATH', 'jawab-notifications')], function () { Route::group(['prefix' => 'api'], function () { Route::get('countries', 'Api\Admin\CountryController@index'); //... }); });
CountryController.php web route file
public function index(Request $request) { $mobile_os = $request->get('os'); return User::select(['phone_country_code']) ->distinct() ->whereNotNull('phone_country_code') ->where('os', $mobile_os) ->get() ->map(function ($item) { return [ 'value' => $item->phone_country_code, 'text' => $item->phone_country_code, ]; }); }
change notifilable model
cloud-messaging.php config file
[ 'notifiable_model' => \App\Models\User::class, ]
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email trmdy@hotmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.