Browse Source

some bug fix and change in notification and listener

master
mahdihty 4 years ago
parent
commit
f13cdf4d46
  1. 3
      app/Http/Controllers/NotificationController.php
  2. 5
      app/Listeners/BusinessUserCreateNotif.php
  3. 2
      app/Listeners/ProjectUserCreateNotif.php
  4. 1
      app/Notifications/FcmNotification.php
  5. 3
      app/Utilities/HelperClass/NotificationHelper.php

3
app/Http/Controllers/NotificationController.php

@ -9,7 +9,8 @@ class NotificationController extends Controller
{
public function index($business)
{
return Auth::user()->notifications()->where('business_id', $business)->get();
return Auth::user()->notifications()
->where('data->business_id', $business)->get();
}
public function markAsRead($business, $notification)

5
app/Listeners/BusinessUserCreateNotif.php

@ -36,11 +36,12 @@ class BusinessUserCreateNotif
$payload = $event->message;
if ($payload->data->original->level === enum('levels.inactive.id')) {
// When user level in business is zero, probably user added to business by system
// And not necessary send notification to stockholders
// And not necessary send notification to stakeholders
return;
}
$new_user = User::findOrFail($payload->data->original->user_id);
$owners = Business::findOrFail($payload->business)->owners()->where('id', '!=', $new_user->id)->get();
$owners = Business::findOrFail($payload->business)->owners()
->whereNotIn('id', [$new_user->id, auth()->id()])->get();
$users = $owners->prepend($new_user);

2
app/Listeners/ProjectUserCreateNotif.php

@ -37,7 +37,7 @@ class ProjectUserCreateNotif
$new_user = User::findOrFail($payload->data->original->user_id);
$project = Project::findOrFail($payload->data->original->project_id);
$owners_id = request('_business_info')['info']['projects'][$project->id]['members']->reject(function ($item, $key) use ($new_user) {
return $item['level'] < enum('levels.owner.id') || $key === $new_user->id;
return $item['level'] < enum('levels.owner.id') || $key === $new_user->id || $key === auth()->id();
})->toArray();
$owners = User::whereIn('id', array_keys($owners_id))->get();

1
app/Notifications/FcmNotification.php

@ -45,6 +45,7 @@ class FcmNotification extends Notification
->data([
'title' => $this->message['title'],
'body' => $this->message['body'],
'openURL' => "https://facebook.com/"
]);
}

3
app/Utilities/HelperClass/NotificationHelper.php

@ -27,7 +27,8 @@ class NotificationHelper
'greeting' => $this->getMessageLine($payload, $route.'greeting'),
'subject' => $this->getMessageLine($payload, $route.'subject'),
'title' => $this->getMessageLine($payload, $route.'title'),
'body' => $this->getMessageLine($payload, $route.'body', $options)
'body' => $this->getMessageLine($payload, $route.'body', $options),
'business_id' => request('_business_info')['id']
];
return $this;
}

Loading…
Cancel
Save