|
@ -2,10 +2,12 @@ |
|
|
|
|
|
|
|
|
namespace App\Listeners; |
|
|
namespace App\Listeners; |
|
|
|
|
|
|
|
|
|
|
|
use App\Channels\FcmChannel; |
|
|
use App\Events\BusinessUserCreate; |
|
|
use App\Events\BusinessUserCreate; |
|
|
use App\Models\Business; |
|
|
use App\Models\Business; |
|
|
use App\Models\User; |
|
|
use App\Models\User; |
|
|
use App\Notifications\DBNotification; |
|
|
use App\Notifications\DBNotification; |
|
|
|
|
|
use App\Notifications\FcmNotification; |
|
|
use App\Notifications\MailNotification; |
|
|
use App\Notifications\MailNotification; |
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
|
use Illuminate\Queue\InteractsWithQueue; |
|
|
use Illuminate\Queue\InteractsWithQueue; |
|
@ -36,11 +38,15 @@ class BusinessUserCreateNotif |
|
|
$owners = Business::findOrFail($payload->business)->owners()->where('id', '!=', $new_user->id)->get(); |
|
|
$owners = Business::findOrFail($payload->business)->owners()->where('id', '!=', $new_user->id)->get(); |
|
|
|
|
|
|
|
|
$notif = [ |
|
|
$notif = [ |
|
|
'body' => __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name'), ['business' => request('_business_info')['name'], 'user' => $new_user->name]) |
|
|
|
|
|
|
|
|
'greeting' => __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name').'.greeting'), |
|
|
|
|
|
'subject' => __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name').'.subject'), |
|
|
|
|
|
'title' => __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name').'.title'), |
|
|
|
|
|
'body' => __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name').'.body', ['business' => request('_business_info')['name'], 'user' => $new_user->name]) |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
$users = $owners->prepend($new_user); |
|
|
$users = $owners->prepend($new_user); |
|
|
Notification::send($users, new MailNotification($notif)); |
|
|
Notification::send($users, new MailNotification($notif)); |
|
|
Notification::send($users, new DBNotification($notif)); |
|
|
Notification::send($users, new DBNotification($notif)); |
|
|
|
|
|
Notification::send($users, new FcmNotification($notif)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |