api code global jain

This commit is contained in:
Abhishek Mali
2025-11-05 10:37:10 +05:30
commit 52fe7e2bec
2834 changed files with 1784903 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Jobs\Notifications\Chaturmas;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendApproveChaturmas implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $chaturmasData;
/**
*
*/
public function __construct($sant, $user, $chaturmasData)
{
$this->sant = $sant;
$this->user = $user;
$this->chaturmasData = $chaturmasData;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->chaturmasData->created_by)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.chaturmas_approved',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.sant.chaturmas_approved');
$pushData['image'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.chaturmas-approved');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for send back sant
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.chaturmas_approved');
$notificationData['user_id'] = $this->chaturmasData->created_by;
$notificationData['type'] = trans('notifications.sant_notification_type.chaturmas-approved');
$notificationData['title'] = trans('notifications.notification_title.chaturmas_approved',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sant->name ?? '';
$extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->chaturmasData->created_by, $users)) {
$users[$this->chaturmasData->created_by] = $this->chaturmasData->created_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->chaturmasData->created_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Jobs\Notifications\Chaturmas;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendNewChaturmas implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($sant, $user)
{
$this->sant = $sant;
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to followers of sant
$followers = $this->sant->followers()->pluck('user_id');
$users = [];
if (!empty($followers)) {
foreach ($followers as $follower) {
$tokens = UserDeviceToken::where('user_id', $follower)
->where('user_id', '!=', $this->user->id)
->get()
->toArray();
$pushData = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.chaturmas_added',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.chaturmas_added');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['from_id'] = $this->sant->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.chaturmas-added');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
if ($follower != $this->user->id) {
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.chaturmas_added',['sant' => $this->sant->name]);
$notificationData['user_id'] = $follower;
$notificationData['type'] = trans('notifications.sant_notification_type.chaturmas-added');
$notificationData['title'] = trans('notifications.notification_title.chaturmas_added',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($follower, $users)) {
$users[$follower] = $follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($follower);
}
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace App\Jobs\Notifications\Chaturmas;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendRejectChaturmas implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($sant, $user)
{
$this->sant = $sant;
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->user->id)->get()->toArray();
$data = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$data['userToken'] = $token['token'] ?? [];
$data['title'] = trans('notifications.notification_title.chaturmas_rejected',['sant' => $this->sant->name]);
$data['body'] = trans('notifications.sant.chaturmas_rejected');
$data['image'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$data['from_id'] = $this->sant->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.chaturmas-rejected');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$data['extraData'] = $extraData ?? [];
$this->pushNotification($data, $extraData);
}
}
//Store notification for reject chaturmas
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.chaturmas_rejected');
$notificationData['user_id'] = $this->user->id;
$notificationData['type'] = trans('notifications.sant_notification_type.chaturmas-rejected');
$notificationData['title'] = trans('notifications.notification_title.chaturmas_rejected',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sant->name ?? '';
$extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->user->id, $users)) {
$users[$this->user->id] = $this->user->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->user->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace App\Jobs\Notifications\Chaturmas;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUpdateChaturmas implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $chaturmas;
/**
*
*/
public function __construct($sant, $user, $chaturmas)
{
$this->sant = $sant;
$this->user = $user;
$this->chaturmas = $chaturmas;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to followers of sant
$followers = $this->sant->followers()->pluck('user_id');
$users = [];
if (!empty($followers)) {
foreach ($followers as $follower) {
$tokens = UserDeviceToken::where('user_id', $follower)
->where('user_id', '!=', $this->user->id)
->get()
->toArray();
$pushData = [];
if ($follower != $this->user->id) {
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['notId'] = $this->chaturmas->id ?? 1;
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.chaturmas_updated',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.chaturmas_updated_push');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['from_id'] = $this->sant->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.chaturmas-updated');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.chaturmas_updated',['sant' => $this->sant->name]);
$notificationData['user_id'] = $follower;
$notificationData['type'] = trans('notifications.sant_notification_type.chaturmas-updated');
$notificationData['title'] = trans('notifications.notification_title.chaturmas_updated',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($follower, $users)) {
$users[$follower] = $follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($follower);
}
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace App\Jobs\Notifications\NewApp;
use App\Constant\Constant;
use App\Models\UserDeviceToken;
use App\Traits\PushNotificationTraits;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class SendDownloadNewApp implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$users = UserDeviceToken::with('user')->whereHas('user', function ($query) {
$query->where('app_version', Constant::STATUS_ZERO);
})->get();
$pushData = [];
foreach ($users as $user) {
$pushData['userToken'] = $user->token ?? [];
$pushData['title'] = trans('notifications.notification_title.new_app');
$pushData['body'] = trans('notifications.new_application.download_app', ['url' => 'https://play.google.com/store/apps/details?id=com.globaljain.android']);
$extraData = [];
$extraData['user_id'] = $user->user_id ?? '';
$extraData['user_name'] = $user->user->name ?? '';
$extraData['url'] = env('NEW_APP_URL');
$extraData['type'] = trans('notifications.app_notification_type.new-app');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $user->os ? getPlatform($user->os) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
//Store notification for send back sant
$notificationData = [];
$notificationData['body'] = trans('notifications.new_application.download_app', ['url' => 'https://play.google.com/store/apps/details?id=com.globaljain.android']);
$notificationData['type'] = trans('notifications.app_notification_type.new-app');
$notificationData['title'] = trans('notifications.notification_title.new_app');
$notificationData['user_id'] = $user->user_id ?? '';;
$extraNotificationData = [];
$extraNotificationData['user_id'] = $user->user_id ?? '';
$extraNotificationData['name'] = $user->user->name ?? '';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($user->user_id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Jobs\Notifications\Post;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendCommentPost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $post;
/**
*
*/
public function __construct($user, $post)
{
$this->user = $user;
$this->post = $post;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user on comment
$tokens = UserDeviceToken::where('user_id', $this->post->created_by)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.comment_post');
$pushData['body'] = trans('notifications.push_post.comment',['user' => $this->user->name]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->post->id;
$extraData = [];
$extraData['from_id'] = $this->post->id;
$extraData['user_id'] = $this->user->id;
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'shravak';
$extraData['type'] = trans('notifications.post_notification_type.comment-post');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.post.comment');
$notificationData['user_id'] = $this->post->created_by;
$notificationData['type'] = trans('notifications.post_notification_type.comment-post');
$notificationData['title'] = trans('notifications.notification_title.comment_post');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->post->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->post->created_by, $users)) {
$users[$this->post->created_by] = $this->post->created_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->post->created_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Jobs\Notifications\Post;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendLikePost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $post;
/**
*
*/
public function __construct($user, $post)
{
$this->user = $user;
$this->post = $post;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user on like
$tokens = UserDeviceToken::where('user_id', $this->post->created_by)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.like_post');
$pushData['body'] = trans('notifications.push_post.like',['user' => $this->user->name]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->post->id;
$extraData = [];
$extraData['from_id'] = $this->post->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'shravak';
$extraData['type'] = trans('notifications.post_notification_type.like-post');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.post.like');
$notificationData['user_id'] = $this->post->created_by;
$notificationData['type'] = trans('notifications.post_notification_type.like-post');
$notificationData['title'] = trans('notifications.notification_title.like_post');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->post->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->post->created_by, $users)) {
$users[$this->post->created_by] = $this->post->created_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->post->created_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Jobs\Notifications\Post;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendNewPostForSanghPost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $post;
/**
* @var
*/
protected $follower;
/**
*
*/
public function __construct($sangh, $post, $follower)
{
$this->sangh = $sangh;
$this->post = $post;
$this->follower = $follower;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to follower of sangh
$tokens = UserDeviceToken::where('user_id', $this->follower)
->get()
->toArray();
$pushData = [];
$users = [];
if($tokens) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.new_sangh_post', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.push_sangh.new_sangh_post');
$pushData['image'] = $this->sangh->avatar ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->post->id;
$extraData = [];
$extraData['from_id'] = $this->post->id;
$extraData['sangh_id'] = $this->sangh->id;
$extraData['user_id'] = loggedInUser()->id ?? '';
$extraData['user_name'] = $this->sangh->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.new-sangh-post');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.new_sangh_post');
$notificationData['user_id'] = $this->follower;
$notificationData['type'] = trans('notifications.sangh_notification_type.new-sangh-post');
$notificationData['title'] = trans('notifications.notification_title.new_sangh_post', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->post->id ?? '';
$extraNotificationData['user_id'] = loggedInUser()->id ?? '';
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = $this->sangh->avatar ? $this->sangh->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->follower, $users)) {
$users[$this->follower] = $this->follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->follower);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace App\Jobs\Notifications\Post;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendNewPostToFriends implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $post;
/**
* @var
*/
protected $friend;
/**
*
*/
public function __construct($user, $post, $friend)
{
$this->user = $user;
$this->post = $post;
$this->friend = $friend;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to friends
$tokens = UserDeviceToken::where('user_id', $this->friend)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.user_friend_post');
$pushData['body'] = trans('notifications.push_friend_post.new_post',['user' => $this->user->name]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->post->id;
$extraData = [];
$extraData['from_id'] = $this->post->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'shravak';
$extraData['type'] = trans('notifications.friend_post_type.new-post');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.friend_post.post');
$notificationData['user_id'] = $this->friend;
$notificationData['type'] = trans('notifications.friend_post_type.new-post');
$notificationData['title'] = trans('notifications.notification_title.user_friend_post');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->post->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->friend, $users)) {
$users[$this->friend] = $this->friend;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->friend);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Jobs\Notifications\Post;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendTagPost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $post;
/**
* @var
*/
protected $taggedUser;
/**
*
*/
public function __construct($user, $post, $taggedUser)
{
$this->user = $user;
$this->post = $post;
$this->taggedUser = $taggedUser;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user who got tagged
$tokens = UserDeviceToken::where('user_id', $this->taggedUser)->get()->toArray();
$pushData = [];
$users = [];
// if($tokens && $tokens > 0) {
if (!empty($tokens)) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.tag_post', ['user' => $this->user->name]);
$pushData['body'] = trans('notifications.push_post.tag',['user' => $this->user->name]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->post->id;
$extraData = [];
$extraData['from_id'] = $this->post->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'shravak';
$extraData['type'] = trans('notifications.post_notification_type.tag-post');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.post.tag');
$notificationData['user_id'] = $this->taggedUser;
$notificationData['type'] = trans('notifications.post_notification_type.tag-post');
$notificationData['title'] = trans('notifications.notification_title.tag_post', ['user' => $this->user->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->post->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->taggedUser, $users)) {
$users[$this->taggedUser] = $this->taggedUser;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->taggedUser);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,107 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAdminAcceptSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $member;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($member, $sangh, $roleName)
{
$this->member = $member;
$this->sangh = $sangh;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when admin accepts join request
$tokens = UserDeviceToken::where('user_id', $this->member)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.admin_accepted_sangh_request', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.sangh.admin_accepted_invitation', ['sangh' => $this->sangh->name]);
$pushData['image'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->member ?? '';
$extraData['user_name'] = $this->sangh->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.admin-accepted-member-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.admin_accepted_invitation', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->member;
$notificationData['type'] = trans('notifications.sangh_notification_type.admin-accepted-member-request');
$notificationData['title'] = trans('notifications.notification_title.admin_accepted_sangh_request', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->member ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->member, $users)) {
$users[$this->member] = $this->member;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->member);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,132 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAdminAddUserSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $member;
/**
* @var
*/
protected $roleName;
/**
* @var
*/
protected $isCoreCommittee;
/**
*
*/
public function __construct($user, $sangh, $member, $roleName, $isCoreCommittee)
{
$this->user = $user;
$this->sangh = $sangh;
$this->member = $member;
$this->roleName = $roleName;
$this->isCoreCommittee = $isCoreCommittee;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when admin invites user
$tokens = UserDeviceToken::where('user_id', $this->member)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sangh_added_member', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.push_sangh.sangh_admin_invite_member', ['sangh' => $this->sangh->name, 'role' => $this->roleName ?? 'Member']);
$pushData['image'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->sangh->name ?? '';
$extraData['user_type'] = 'sangh';
if ($this->isCoreCommittee != Constant::NULL) {
$extraData['type'] = trans('notifications.sangh_notification_type.sangh-added-committee-member');
} else {
$extraData['type'] = trans('notifications.sangh_notification_type.sangh-added-member');
}
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.sangh_admin_invite_member', ['role' => $this->roleName ?? 'Member']);
$notificationData['user_id'] = $this->member;
if ($this->isCoreCommittee != Constant::NULL) {
$notificationData['type'] = trans('notifications.sangh_notification_type.sangh-added-committee-member');
} else {
$notificationData['type'] = trans('notifications.sangh_notification_type.sangh-added-member');
}
$notificationData['title'] = trans('notifications.notification_title.sangh_added_member', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->user->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['add_member'] = true;
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $this->roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->member, $users)) {
$users[$this->member] = $this->member;
$this->storeNotification($notificationData);
unreadNotificationCounter($this->member); //Unread count increament
unreadSanghInviteCounter($this->member, Constant::STATUS_ONE); //Pending invitation badge
unreadSanghMenuCounter($this->member, Constant::STATUS_ONE); //Pending sangh menu badge
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,107 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAdminDeclineSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($user, $sangh, $roleName)
{
$this->user = $user;
$this->sangh = $sangh;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when admin declines join request
$tokens = UserDeviceToken::where('user_id', $this->user->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.admin_declined_sangh_request', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.sangh.admin_declined_invitation', ['sangh' => $this->sangh->name]);
$pushData['image'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->sangh->id ?? '';
$extraData['user_name'] = $this->sangh->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.admin-declined-member-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.admin_declined_invitation', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->user->id;
$notificationData['type'] = trans('notifications.sangh_notification_type.admin-declined-member-request');
$notificationData['title'] = trans('notifications.notification_title.admin_declined_sangh_request', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->sangh->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $this->roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->user->id, $users)) {
$users[$this->user->id] = $this->user->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->user->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAdminRemoveMember implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $userId;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($userId, $sangh, $roleName)
{
$this->userId = $userId;
$this->sangh = $sangh;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when admin removes from sangh
$tokens = UserDeviceToken::where('user_id', $this->userId)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.admin_removed_sangh_member', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.push_sangh.admin_remove_member', ['sangh' => $this->sangh->name]);
$pushData['image'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['user_id'] = $this->sangh->id ?? '';
$extraData['user_name'] = $this->sangh->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.admin-removed-member');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.admin_remove_member', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->userId;
$notificationData['type'] = trans('notifications.sangh_notification_type.admin-removed-member');
$notificationData['title'] = trans('notifications.notification_title.admin_removed_sangh_member', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->sangh->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->userId, $users)) {
$users[$this->userId] = $this->userId;
$this->storeNotification($notificationData);
//Unread notification count increament
unreadNotificationCounter($this->userId);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAdminUpdateRole implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $memberId;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($user, $memberId, $sangh, $roleName)
{
$this->user = $user;
$this->memberId = $memberId;
$this->sangh = $sangh;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when admin updates role
$tokens = UserDeviceToken::where('user_id', $this->memberId)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sangh_updated_member', ['role' => $this->roleName, 'sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.push_sangh.admin_updated_member', ['sangh' => $this->sangh->name]);
$pushData['image'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.sangh-updated-member');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.admin_updated_member', ['role' => $this->roleName]);
$notificationData['user_id'] = $this->memberId;
$notificationData['type'] = trans('notifications.sangh_notification_type.sangh-updated-member');
$notificationData['title'] = trans('notifications.notification_title.sangh_updated_member', ['role' => $this->roleName,'sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $this->roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->memberId, $users)) {
$users[$this->memberId] = $this->memberId;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->memberId);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendApproveSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($user, $sangh)
{
$this->user = $user;
$this->sangh = $sangh;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
$tokens = UserDeviceToken::where('user_id', $this->sangh->updated_by)->get()->toArray();
$pushData = [];
$users = [];
if ($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sangh_approved', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.sangh.sangh_approved');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->user->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['type'] = trans('notifications.sangh_notification_type.sangh-approved');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for approved sangh
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.sangh_approved');
$notificationData['user_id'] = $this->sangh->updated_by;
$notificationData['type'] = trans('notifications.sangh_notification_type.sangh-approved');
$notificationData['title'] = trans('notifications.notification_title.sangh_approved', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->sangh->updated_by, $users)) {
$users[$this->sangh->updated_by] = $this->sangh->updated_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->sangh->updated_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Models\UserDeviceToken;
use App\Traits\PushNotificationTraits;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendCreateSanghUser implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $allUser;
/**
*
*/
public function __construct($sangh, $allUser)
{
$this->sangh = $sangh;
$this->allUser = $allUser;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try
{
$users = [];
foreach ($this->allUser as $user) {
$tokens = UserDeviceToken::where('user_id', $user->id)->get()->toArray();
$pushData = [];
if (!empty($tokens)) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? '';
$pushData['title'] = trans('notifications.notification_title.sangh_created', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.notification_title.sangh_descreption', ['sangh' => $this->sangh->name]);
$pushData['image'] = ($user->avatar) ? $user->avatar : "";
$pushData['from_id'] = $user->id;
$extraData = [
'user_id' => $user->id ?? '',
'user_name' => $user->name ?? '',
'type' => trans('notifications.sangh_notification_type.created_sangh'),
'created_at' => now()->format('Y/m/d H:i:s'),
'os' => $token['os'] ? getPlatform($token['os']) : ''
];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for created sangh
$notificationData = [];
$notificationData['user_id'] = $user->id;
$notificationData['type'] = trans('notifications.sangh_notification_type.created_sangh');
$notificationData['title'] = trans('notifications.notification_title.sangh_created', ['sangh' => $this->sangh->name]);
$notificationData['body'] = trans('notifications.notification_title.sangh_descreption', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $user->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = $this->sangh->avatar ?? '';
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($user->id, $users)) {
$users[$user->id] = $user->id;
$this->storeNotification($notificationData);
unreadNotificationCounter($user->id);
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendRejectSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($user, $sangh)
{
$this->user = $user;
$this->sangh = $sangh;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
$tokens = UserDeviceToken::where('user_id', $this->sangh->updated_by)->get()->toArray();
$pushData = [];
$users = [];
if ($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sangh_rejected', ['sangh' => $this->sangh->name]);
// $pushData['body'] = $this->sangh->reject_reason;
$pushData['body'] = trans('notifications.push_sangh.sangh_rejected', ['reason' => $this->sangh->reject_reason]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->user->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['type'] = trans('notifications.sangh_notification_type.sangh-rejected');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for rejected sangh
$notificationData = [];
$notificationData['body'] = trans('notifications.push_sangh.sangh_rejected', ['reason' => $this->sangh->reject_reason]);
$notificationData['user_id'] = $this->sangh->updated_by;
$notificationData['type'] = trans('notifications.sangh_notification_type.sangh-rejected');
$notificationData['title'] = trans('notifications.notification_title.sangh_rejected', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sangh->name ?? '';
$extraNotificationData['avatar'] = ($this->sangh->avatar) ? $this->sangh->avatar : "";
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->sangh->updated_by, $users)) {
$users[$this->sangh->updated_by] = $this->sangh->updated_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->sangh->updated_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,119 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUserAcceptSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $committeeMember;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($loggedInUser, $user, $sangh, $committeeMember, $roleName)
{
$this->loggedInUser = $loggedInUser;
$this->user = $user;
$this->sangh = $sangh;
$this->committeeMember = $committeeMember;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to admin when user accepts join request
$tokens = UserDeviceToken::where('user_id', $this->committeeMember)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = $this->sangh->name;
$pushData['body'] = trans('notifications.push_sangh.user_accepted_invitation', ['user' => $this->loggedInUser->name, 'sangh' => $this->sangh->name]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.user-accepted-member-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.user_accepted_invitation', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->committeeMember;
$notificationData['type'] = trans('notifications.sangh_notification_type.user-accepted-member-request');
$notificationData['title'] = trans('notifications.notification_title.user_accepted_sangh_request', ['user' => $this->loggedInUser->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->user->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $this->roleName;
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->committeeMember, $users)) {
$users[$this->committeeMember] = $this->committeeMember;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->committeeMember);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,119 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUserDeclineSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $committeeMember;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($loggedInUser, $user, $sangh, $committeeMember, $roleName)
{
$this->loggedInUser = $loggedInUser;
$this->user = $user;
$this->sangh = $sangh;
$this->committeeMember = $committeeMember;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to admin when user declines join request
$tokens = UserDeviceToken::where('user_id', $this->committeeMember)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = $this->sangh->name;
$pushData['body'] = trans('notifications.push_sangh.user_declined_invitation', ['user' => $this->loggedInUser->name, 'sangh' => $this->sangh->name]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.user-declined-member-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sangh.user_declined_invitation', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->committeeMember;
$notificationData['type'] = trans('notifications.sangh_notification_type.user-declined-member-request');
$notificationData['title'] = trans('notifications.notification_title.user_declined_sangh_request', ['user' => $this->loggedInUser->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->user->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['role'] = $this->roleName;
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->committeeMember, $users)) {
$users[$this->committeeMember] = $this->committeeMember;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->committeeMember);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,122 @@
<?php
namespace App\Jobs\Notifications\Sangh;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUserJoinedSangh implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $sangh;
/**
* @var
*/
protected $sanghMemberId;
/**
* @var
*/
protected $coreMember;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($user, $sangh, $sanghMemberId, $coreMember, $roleName)
{
$this->user = $user;
$this->sangh = $sangh;
$this->sanghMemberId = $sanghMemberId;
$this->coreMember = $coreMember;
$this->roleName = $roleName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to admin when user send join request
$tokens = UserDeviceToken::where('user_id', $this->sanghMemberId)->with('user')->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.user_sent_join_request', ['sangh' => $this->sangh->name]);
$pushData['body'] = trans('notifications.push_sangh.user_sent_join_request', ['user' => $this->user->name, 'sangh' => $this->sangh->name]);
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sangh->id;
$extraData = [];
$extraData['from_id'] = $this->sangh->id;
$extraData['user_id'] = $this->sanghMemberId ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sangh';
$extraData['type'] = trans('notifications.sangh_notification_type.user-sent-member-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = ($this->roleName) ? trans('notifications.sangh.user_sent_join_request_with_role', ['sangh' => $this->sangh->name, 'role' => $this->roleName]) : trans('notifications.sangh.user_sent_join_request', ['sangh' => $this->sangh->name]);
$notificationData['user_id'] = $this->sanghMemberId;
$notificationData['type'] = trans('notifications.sangh_notification_type.user-sent-member-request');
$notificationData['title'] = trans('notifications.notification_title.sangh_added_member', ['sangh' => $this->sangh->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->user->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['sangh_id'] = $this->sangh->id ?? '';
$extraNotificationData['sangh_name'] = $this->sangh->name ?? '';
$extraNotificationData['add_member'] = $this->coreMember;
$extraNotificationData['role'] = $this->roleName ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'sangh';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->sanghMemberId, $users)) {
$users[$this->sanghMemberId] = $this->sanghMemberId;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->sanghMemberId);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,100 @@
<?php
namespace App\Jobs\Notifications\Sant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendApproveSant implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $santMain;
/**
*
*/
public function __construct($user, $sant, $santMain)
{
$this->user = $user;
$this->sant = $sant;
$this->santMain = $santMain;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->sant->updated_by)->get()->toArray();
$pushData = [];
$users = [];
if ($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sant_approved',['sant' => $this->santMain->name]);
$pushData['body'] = trans('notifications.sant.sant_approved');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->user->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['type'] = trans('notifications.sant_notification_type.sant-approved');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for approved sant
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.sant_approved');
$notificationData['user_id'] = $this->santMain->updated_by;
$notificationData['type'] = trans('notifications.sant_notification_type.sant-approved');
$notificationData['title'] = trans('notifications.notification_title.sant_approved',['sant' => $this->santMain->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->santMain->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->santMain->name ?? '';
$extraNotificationData['avatar'] = ($this->santMain->avatar) ? $this->santMain->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->santMain->updated_by, $users)) {
$users[$this->santMain->updated_by] = $this->santMain->updated_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->santMain->updated_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Jobs\Notifications\Sant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendRejectSant implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $rejectDesc;
/**
*
*/
public function __construct($user, $sant, $rejectDesc)
{
$this->user = $user;
$this->sant = $sant;
$this->rejectDesc = $rejectDesc;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->sant->updated_by)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sant_rejected',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.sant_rejected');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->sant_id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.sant-rejected');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for rejected sant
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.sant_rejected',['reason' => $this->rejectDesc]);
$notificationData['user_id'] = $this->sant->updated_by;
$notificationData['type'] = trans('notifications.sant_notification_type.sant-rejected');
$notificationData['title'] = trans('notifications.notification_title.sant_rejected',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->sant_id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sant->name ?? '';
$extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->sant->updated_by, $users)) {
$users[$this->sant->updated_by] = $this->sant->updated_by;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->sant->updated_by);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace App\Jobs\Notifications\Sant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendRejectThana implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $thana;
/**
* @var
*/
protected $removedSant;
/**
*
*/
public function __construct($thana, $removedSant)
{
$this->thana = $thana;
$this->removedSant = $removedSant;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->thana->created_by)->get()->toArray();
$pushData = [];
$users = [];
if ($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$data['userToken'] = $token['token'] ?? [];
$data['title'] = trans('notifications.notification_title.thana_rejected');
$data['body'] = trans('notifications.sant.thana_rejected',['sant' => $this->removedSant->name]);
$data['image'] = ($this->removedSant->avatar) ? $this->removedSant->avatar : "";
$data['from_id'] = $this->removedSant->id;
$extraData = [];
$extraData['user_id'] = $this->thana['created_by'] ?? '';
$extraData['user_name'] = $this->removedSant->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.thana-rejected');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$data['extraData'] = $extraData ?? [];
$this->pushNotification($data, $extraData);
}
}
//Store notification for reject thana
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.thana_rejected',['sant' => $this->removedSant->name]);
$notificationData['user_id'] = $this->thana['created_by'];
$notificationData['type'] = trans('notifications.sant_notification_type.thana-rejected');
$notificationData['title'] = trans('notifications.notification_title.thana_rejected');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->removedSant->id ?? '';
$extraNotificationData['user_id'] = $this->thana['created_by'] ?? '';
$extraNotificationData['name'] = $this->removedSant->name ?? '';
$extraNotificationData['avatar'] = ($this->removedSant->avatar) ? $this->removedSant->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->thana['created_by'], $users)) {
$users[$this->thana['created_by']] = $this->thana['created_by'];
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->thana['created_by']);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Jobs\Notifications\Sant;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendSantLocationChange implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($user, $sant)
{
$this->user = $user;
$this->sant = $sant;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$followers = $this->sant->followers()->pluck('user_id');
$users = [];
if (!empty($followers)) {
foreach ($followers as $follower) {
$tokens = UserDeviceToken::where('user_id', $follower)
->where('user_id', '!=', $this->user->id)
->get()
->toArray();
$pushData = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.location_update',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.location_update',['sant' => $this->sant->name, 'user' => $this->user->name]);
$pushData['image'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['from_id'] = $this->sant->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.update-location');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
if ($follower != $this->user->id) {
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.location_update',['sant' => "<b>".$this->sant->name."</b>", 'user' => $this->user->name]);
$notificationData['user_id'] = $follower;
$notificationData['type'] = trans('notifications.sant_notification_type.update-location');
$notificationData['title'] = trans('notifications.notification_title.location_update',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sant->name ?? '';
$extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($follower, $users)) {
$users[$follower] = $follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($follower);
}
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Jobs\Notifications\Sant;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendSentBackSant implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $senBackDesc;
/**
*
*/
public function __construct($user, $sant, $senBackDesc)
{
$this->user = $user;
$this->sant = $sant;
$this->senBackDesc = $senBackDesc;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to shravak who added
$tokens = UserDeviceToken::where('user_id', $this->sant->updated_by)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.sant_send_back',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.sant_send_back');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->sant_id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.sant-send-back');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store notification for send back sant
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.sant_send_back',['reason' => $this->senBackDesc]);
$notificationData['user_id'] = $this->sant->updated_by;
$notificationData['type'] = trans('notifications.sant_notification_type.sant-send-back');
$notificationData['title'] = trans('notifications.notification_title.sant_send_back',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->sant_id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->sant->name ?? '';
$extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : "";
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->sant->updated_by, $users)) {
$users[$this->sant->updated_by] = $this->sant->updated_by;
$this->storeNotification($notificationData);
unreadNotificationCounter($this->sant->updated_by); //Unread count increament
unreadSantActionCounter($this->sant->updated_by, Constant::STATUS_ONE); //Pending sant action badge
unreadSantMenuCounter($this->sant->updated_by, Constant::STATUS_ONE); //Pending sant menu badge
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAcceptFriendRequest implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $receiver;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($loggedInUser, $receiver)
{
$this->loggedInUser = $loggedInUser;
$this->receiver = $receiver;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when someone accepts friend request
$tokens = UserDeviceToken::where('user_id', $this->receiver->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.friend_request_accepted',['user' => $this->loggedInUser->name]);
$pushData['body'] = trans('notifications.push_friend_request.accept_request',['user' => $this->loggedInUser->name]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->loggedInUser->id;
$extraData = [];
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'friendRequest';
$extraData['type'] = trans('notifications.friend_request_notification_type.friend-request-accepted');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.friend_request.accept_request');
$notificationData['user_id'] = $this->receiver->id;
$notificationData['type'] = trans('notifications.friend_request_notification_type.friend-request-accepted');
$notificationData['title'] = trans('notifications.notification_title.friend_request_accepted',['user' => $this->loggedInUser->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->receiver->id, $users)) {
$users[$this->receiver->id] = $this->receiver->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->receiver->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendAcceptRelationRequest implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $receiver;
/**
* @var
*/
protected $roleName;
/**
* @var
*/
protected $requestExist;
/**
*
*/
public function __construct($loggedInUser, $receiver, $requestExist)
{
$this->loggedInUser = $loggedInUser;
$this->receiver = $receiver;
$this->requestExist = $requestExist;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when someone accepts friend request
$tokens = UserDeviceToken::where('user_id', $this->receiver->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.relationship_request_accepted',['user' => $this->loggedInUser->name]);
$pushData['body'] = trans('notifications.push_relationship.accept_request',['user' => $this->loggedInUser->name]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->loggedInUser->id;
$extraData = [];
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'relationRequest';
$extraData['type'] = trans('notifications.relationship_notification_type.relationship-request-accepted');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.relationship.accept_request');
$notificationData['user_id'] = $this->receiver->id;
$notificationData['type'] = trans('notifications.relationship_notification_type.relationship-request-accepted');
$notificationData['title'] = trans('notifications.notification_title.relationship_request_accepted',['user' => $this->loggedInUser->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['relation'] = $this->requestExist->relation ?? '';
$extraNotificationData['relation_request_status'] = Constant::STATUS_ONE ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->receiver->id, $users)) {
$users[$this->receiver->id] = $this->receiver->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->receiver->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendFriendRequest implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $receiver;
/**
* @var
*/
protected $roleName;
/**
*
*/
public function __construct($loggedInUser, $receiver)
{
$this->loggedInUser = $loggedInUser;
$this->receiver = $receiver;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when someone send friend request
$tokens = UserDeviceToken::where('user_id', $this->receiver->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.new_friend_request',['user' => $this->loggedInUser->name]);
$pushData['body'] = trans('notifications.push_friend_request.new_request',['user' => $this->loggedInUser->name]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->loggedInUser->id;
$extraData = [];
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'friendRequest';
$extraData['type'] = trans('notifications.friend_request_notification_type.friend-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.friend_request.new_request');
$notificationData['user_id'] = $this->receiver->id;
$notificationData['type'] = trans('notifications.friend_request_notification_type.friend-request');
$notificationData['title'] = trans('notifications.notification_title.new_friend_request',['user' => $this->loggedInUser->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->receiver->id, $users)) {
$users[$this->receiver->id] = $this->receiver->id;
$this->storeNotification($notificationData);
unreadNotificationCounter($this->receiver->id); //Unread count increament
unreadFriendRequestCounter($this->receiver->id, Constant::STATUS_ONE); //Pending request badge
unreadShravakMenuCounter($this->receiver->id, Constant::STATUS_ONE); //Pending shravak menu badge
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendNewSignUp implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $allUsers;
/**
*
*/
public function __construct($user, $allUsers)
{
$this->user = $user;
$this->allUsers = $allUsers;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to all users
if (!empty($this->allUsers)) {
foreach ($this->allUsers as $userId) {
$tokens = UserDeviceToken::where('user_id', $userId)
->get()
->toArray();
$pushData = [];
$users = [];
if ($userId != $this->user->id) {
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.new_sign_up',['user' => $this->user->name]);
$pushData['body'] = trans('notifications.push_register.new_sign_up');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->user->id;
$extraData = [];
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'shravak';
$extraData['type'] = trans('notifications.register_type.new-sign-up');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.register.new_sign_up',['user' => $this->user->name]);
$notificationData['user_id'] = $userId;
$notificationData['type'] = trans('notifications.register_type.new-sign-up');
$notificationData['title'] = trans('notifications.notification_title.new_sign_up',['user' => $this->user->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->user->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($userId, $users)) {
$users[$userId] = $userId;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($userId);
}
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendRelationRequest implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $receiver;
/**
* @var
*/
protected $relationName;
/**
*
*/
public function __construct($loggedInUser, $receiver, $relationName)
{
$this->loggedInUser = $loggedInUser;
$this->receiver = $receiver;
$this->relationName = $relationName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when someone send friend request
$tokens = UserDeviceToken::where('user_id', $this->receiver->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.new_relationship_request');
$pushData['body'] = trans('notifications.push_relationship.relation_request',['user' => $this->loggedInUser->name,'relation' => $this->relationName]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->loggedInUser->id;
$extraData = [];
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = 'relationRequest';
$extraData['type'] = trans('notifications.relationship_notification_type.relationship-request');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.relationship.relation_request',['relation' => $this->relationName]);
$notificationData['user_id'] = $this->receiver->id;
$notificationData['type'] = trans('notifications.relationship_notification_type.relationship-request');
$notificationData['title'] = trans('notifications.notification_title.new_relationship_request');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['relation'] = $data['relation'] ?? '';
$extraNotificationData['relation_request_status'] = Constant::STATUS_ZERO ?? '';
$extraNotificationData['notification_type'] = Constant::STATUS_TWO;
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->receiver->id, $users)) {
$users[$this->receiver->id] = $this->receiver->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->receiver->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Jobs\Notifications\Shravak;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUpdateRelationRequest implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $loggedInUser;
/**
* @var
*/
protected $receiver;
/**
* @var
*/
protected $relationName;
/**
*
*/
public function __construct($loggedInUser, $receiver, $relationName)
{
$this->loggedInUser = $loggedInUser;
$this->receiver = $receiver;
$this->relationName = $relationName;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to user when someone send friend request
$tokens = UserDeviceToken::where('user_id', $this->receiver->id)->get()->toArray();
$pushData = [];
$users = [];
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.update_relationship_request', ['user' => $this->loggedInUser->name]);
$pushData['body'] = trans('notifications.push_relationship.update_relation_request', ['user' => $this->loggedInUser->name,'relation' => $this->relationName]);
$pushData['image'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$pushData['from_id'] = $this->loggedInUser->id;
$extraData = [];
$extraData['user_id'] = $this->loggedInUser->id ?? '';
$extraData['user_name'] = $this->loggedInUser->name ?? '';
$extraData['user_type'] = trans('notifications.relationship_notification_type.relationship-request-updated');
$extraData['type'] = trans('notifications.relationship_notification_type.relationship-request-updated');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.relationship.update_relation_request',['relation' => $this->relationName]);
$notificationData['user_id'] = $this->receiver->id;
$notificationData['type'] = trans('notifications.relationship_notification_type.relationship-request-updated');
$notificationData['title'] = trans('notifications.notification_title.update_relationship_request_title');
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['user_id'] = $this->loggedInUser->id ?? '';
$extraNotificationData['name'] = $this->loggedInUser->name ?? '';
$extraNotificationData['avatar'] = ($this->loggedInUser->avatar) ? $this->loggedInUser->avatar : "";
$extraNotificationData['relation'] = $this->relationName ?? '';
$extraNotificationData['user_type'] = 'shravak';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($this->receiver->id, $users)) {
$users[$this->receiver->id] = $this->receiver->id;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($this->receiver->id);
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Jobs\Notifications\Vihaar;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendNewVihaar implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
*
*/
public function __construct($sant, $user)
{
$this->sant = $sant;
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to followers of sant
$followers = $this->sant->followers()->pluck('user_id');
$users = [];
if (!empty($followers)) {
foreach ($followers as $follower) {
$tokens = UserDeviceToken::where('user_id', $follower)
->get()
->toArray();
$pushData = [];
if(!empty($tokens)) {
foreach ($tokens as $token) {
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.vihar_added',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.vihar_added');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['from_id'] = $this->sant->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.vihar-added');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.vihar_added',['sant' => $this->sant->name]);
$notificationData['user_id'] = $follower;
$notificationData['type'] = trans('notifications.sant_notification_type.vihar-added');
$notificationData['title'] = trans('notifications.notification_title.vihar_added',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($follower, $users)) {
$users[$follower] = $follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($follower);
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace App\Jobs\Notifications\Vihaar;
use App\Constant\Constant;
use Illuminate\Bus\Queueable;
use App\Models\UserDeviceToken;
use Illuminate\Support\Facades\Log;
use App\Traits\PushNotificationTraits;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SendUpdateVihaar implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PushNotificationTraits;
/**
* @var
*/
protected $sant;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $vihar;
/**
*
*/
public function __construct($sant, $user, $vihar)
{
$this->sant = $sant;
$this->user = $user;
$this->vihar = $vihar;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//Push Notification to followers of sant
$followers = $this->sant->followers()->pluck('user_id');
$users = [];
if (!empty($followers)) {
foreach ($followers as $follower) {
$tokens = UserDeviceToken::where('user_id', $follower)
->where('user_id', '!=', $this->user->id)
->get()
->toArray();
$pushData = [];
if ($follower != $this->user->id) {
if($tokens && $tokens > 0) {
foreach ($tokens as $token) {
$pushData['notId'] = $this->vihar->id ?? 1;
$pushData['userToken'] = $token['token'] ?? [];
$pushData['title'] = trans('notifications.notification_title.vihar_updated',['sant' => $this->sant->name]);
$pushData['body'] = trans('notifications.push_sant.vihar_updated');
$pushData['image'] = ($this->user->avatar) ? $this->user->avatar : "";
$pushData['from_id'] = $this->sant->id;
$extraData = [];
$extraData['from_id'] = $this->sant->id;
$extraData['user_id'] = $this->user->id ?? '';
$extraData['user_name'] = $this->user->name ?? '';
$extraData['user_type'] = 'sant';
$extraData['type'] = trans('notifications.sant_notification_type.vihar-updated');
$extraData['created_at'] = date('Y/m/d H:i:s');
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
$pushData['extraData'] = $extraData ?? [];
$this->pushNotification($pushData, $extraData);
}
}
//Store Notification
$notificationData = [];
$notificationData['body'] = trans('notifications.sant.vihar_updated',['sant' => $this->sant->name]);
$notificationData['user_id'] = $follower;
$notificationData['type'] = trans('notifications.sant_notification_type.vihar-updated');
$notificationData['title'] = trans('notifications.notification_title.vihar_updated',['sant' => $this->sant->name]);
$extraNotificationData = [];
$extraNotificationData['from_id'] = $this->sant->id ?? '';
$extraNotificationData['user_id'] = $this->user->id ?? '';
$extraNotificationData['name'] = $this->user->name ?? '';
$extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : "";
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
$extraNotificationData['user_type'] = 'sant';
$extraNotificationData['created_at'] = date('Y/m/d H:i:s');
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
if (!in_array($follower, $users)) {
$users[$follower] = $follower;
$this->storeNotification($notificationData);
//Unread count increament
unreadNotificationCounter($follower);
}
}
}
}
} catch (\Exception $ex) {
Log::error($ex);
}
}
}