ultimatepos/Modules/Communication/Http/Controllers/DataController.php

77 lines
3.3 KiB
PHP

<?php
namespace Modules\Communication\Http\Controllers;
use App\Http\MenuIcons;
use Illuminate\Routing\Controller;
use Menu;
use Modules\Communication\Entities\Meeting;
class DataController extends Controller
{
public function modifyAdminMenu()
{
if (\Module::has('Communication') && \Module::isEnabled('Communication') && auth()->user()->can('communication.access')) {
Menu::modify('admin-sidebar-menu', function ($menu) {
$menu->dropdown(
__('communication::lang.module_name'),
function ($sub) {
$sub->url(
action([\Modules\Communication\Http\Controllers\ChatController::class, 'index']),
__('communication::lang.chat'),
['active' => request()->segment(1) == 'communication' && request()->segment(2) == 'chat']
);
$sub->url(
action([\Modules\Communication\Http\Controllers\MeetingController::class, 'index']),
__('communication::lang.meetings'),
['active' => request()->segment(1) == 'communication' && request()->segment(2) == 'meetings']
);
},
['icon' => MenuIcons::svg('chat'), 'active' => request()->segment(1) == 'communication', 'data-module' => 'Communication', 'data-menu-group' => 'integrations']
)->order(87);
});
}
}
public function user_permissions()
{
return [
['value' => 'communication.access', 'label' => __('communication::lang.access'), 'default' => false],
['value' => 'communication.chat.create', 'label' => __('communication::lang.create_chat'), 'default' => false],
['value' => 'communication.chat.manage', 'label' => __('communication::lang.manage_chat'), 'default' => false],
['value' => 'communication.meeting.create', 'label' => __('communication::lang.create_meeting'), 'default' => false],
['value' => 'communication.meeting.manage', 'label' => __('communication::lang.manage_meeting'), 'default' => false],
];
}
public function superadmin_package()
{
return [
['name' => 'communication_module', 'label' => __('communication::lang.module_name'), 'default' => false],
];
}
public function parse_notification($notification)
{
if ($notification->type !== 'Modules\Communication\Notifications\MeetingInviteNotification') {
return [];
}
$meeting = Meeting::find($notification->data['meeting_id'] ?? null);
if (! $meeting) {
return [];
}
return [
'msg' => __('communication::lang.meeting_invite_notification', [
'inviter' => $notification->data['inviter_name'] ?? __('lang_v1.unknown'),
'title' => $meeting->title,
]),
'icon_class' => 'fas fa-video bg-blue',
'link' => action([\Modules\Communication\Http\Controllers\MeetingController::class, 'index']),
'read_at' => $notification->read_at,
'created_at' => format_relative_time($notification->created_at),
];
}
}