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
- dev-main
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1.1
- 1.0.1
- 1.0.0
- dev-fcm-api-v2
- dev-added_custome_users_edit
- dev-TargetAudianceFields
- dev-feature/add-event-listeners
- dev-fix/namespace
- dev-fix/time-zone
- dev-fix/redis-delete-notification
- dev-feature/country-timezone
- dev-fix/target-audience-count
- dev-feature/copy-notification
- dev-feature/dynamic-query
- dev-feature/single-select
- dev-feature/guzzle-support
- dev-hotfix-namespace-renaming
This package is auto-updated.
Last update: 2024-10-29 17:02:18 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.