first commit

This commit is contained in:
ExtraNetwork
2026-05-12 17:04:54 +03:00
commit e5c4b6aa13
1425 changed files with 284735 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Notifications;
use App\Channels\OneSignalChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
class DirectPushNotificationUser extends Notification implements ShouldQueue
{
use Queueable;
public $tries = 2;
public $timeout = 60;
public $param;
public function __construct(
$param
)
{
$this->param = $param;
}
public function via($notifyRoutes)
{
return [OneSignalChannel::class];
}
public function toOneSignal($notifyRoutes)
{
/*$param = [
'subject' => 'Otel Bilgileri Güncelleme',
'message' => $params['property_info']['name']. ' Otel Bilgileri Güncellendi.',
'oneSignalPlayerIds' => ['5931bd16-daac-43f4-824c-c953b8902e96']
];
Notification::route('OneSignal', null)->notify(new DirectPushNotificationUser($param));*/
$oneSignalService = App::make("App\Core\Service\OneSignalService");
$restUrl = 'https://onesignal.com/api/v1/notifications';
if (!empty($this->param['oneSignalPlayerIds'])) {
$payloadJson = [
'include_player_ids' => $this->param['oneSignalPlayerIds'],
'headings' => [
'en' => $this->param['subject']
],
'contents' => [
'en' => $this->param['message']
]
];
if (isset($this->param['subtitle'])) {
$payloadJson['subtitle'] = [
'en' => $this->param['subtitle']
];
}
if (isset($this->param['url'])) {
//$payloadJson['url'] = $this->param['url'];
$payloadJson['data']['url'] = $this->param['url'];
}
$sendOneSignalPushNotification = $oneSignalService->sendOneSignalPushNotification($restUrl, $payloadJson);
}
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Notifications;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\HtmlString;
class NewUserNotification extends Notification
{
public $notificationParam;
public function __construct($notificationParam)
{
$this->notificationParam = $notificationParam;
}
public function via($notificationReceiver)
{
return ['mail'];
}
public function toMail($notificationReceiver)
{
$notificationParam = $this->notificationParam;
$MailMessage = (new MailMessage)
->subject('Extranetwork New User')
->from(config('mail.from.address'), config('mail.from.name'))
->greeting('Extranetwork App New User')
->line(new HtmlString('<br><b>Name Surname:</b> '.$notificationParam['name'].' '.$notificationParam['surname']))
->line(new HtmlString('<b>Property Name:</b> '.$notificationParam['property_name']))
->line(new HtmlString('<b>E-Mail:</b> '.$notificationParam['email']))
->line(new HtmlString('<b>Phone:</b> '.$notificationParam['phone']))
->line(new HtmlString('<b>Language:</b> '.$notificationParam['language']))
->line(new HtmlString('<b>Time:</b> '. Carbon::now()->format('d.m.Y H:i:s')));
//echo $MailMessage->render(); die();
return $MailMessage;
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace App\Notifications;
use App\Channels\OneSignalChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
class PushNotificationPropertyUser extends Notification implements ShouldQueue
{
use Queueable;
public $tries = 2;
public $timeout = 60;
public $param;
public function __construct(
$param
)
{
$this->param = $param;
}
public function via($notifyRoutes)
{
return [OneSignalChannel::class];
}
public function toOneSignal($notifyRoutes)
{
$oneSignalService = App::make("App\Core\Service\OneSignalService");
$userPropertyMappingService = App::make("App\Core\Service\UserPropertyMappingService");
$restUrl = 'https://onesignal.com/api/v1/notifications';
if (isset($this->param['property_id']) && !empty($this->param['property_id'])) {
$propertyUserListRequest = [
'criteria' => [
['field' => 'status', 'condition' => '=', 'value' => 1],
['field' => 'property_id', 'condition' => '=', 'value' => $this->param['property_id']],
],
'with' => ['user']
];
$propertyUserList = $userPropertyMappingService->select($propertyUserListRequest);
if ($propertyUserList['status'] == 'success') {
$propertyUserListCollection = collect($propertyUserList['data']);
$oneSignalPlayerIds = $propertyUserListCollection->where('user.onesignal_key', '!=', null)->pluck('user.onesignal_key')->toArray();
if (!empty($oneSignalPlayerIds)) {
$payloadJson = [
'include_player_ids' => $oneSignalPlayerIds,
'headings' => [
'en' => $this->param['subject']
],
'contents' => [
'en' => $this->param['message']
]
];
if (isset($this->param['subtitle'])) {
$payloadJson['subtitle'] = [
'en' => $this->param['subtitle']
];
}
if (isset($this->param['url'])) {
//$payloadJson['url'] = $this->param['url'];
$payloadJson['data']['url'] = $this->param['url'];
}
$sendOneSignalPushNotification = $oneSignalService->sendOneSignalPushNotification($restUrl, $payloadJson);
}
}
}
}
}