fixed notifications

This commit is contained in:
Denis Duliçi 2020-07-13 15:16:56 +03:00
parent 0467a9f49d
commit a067866de5
3 changed files with 11 additions and 14 deletions

View File

@ -2,13 +2,13 @@
namespace App\Http\ViewComposers; namespace App\Http\ViewComposers;
use App\Traits\Modules;
use Route; use Route;
use Illuminate\View\View; use Illuminate\View\View;
use App\Traits\Modules as RemoteModules;
class Notifications class Notifications
{ {
use RemoteModules; use Modules;
/** /**
* Bind data to the view. * Bind data to the view.
@ -23,30 +23,27 @@ class Notifications
return; return;
} }
$path = Route::current()->uri(); if (!$path = Route::current()->uri()) {
if (empty($path)) {
return; return;
} }
$notifications = $this->getNotifications($path); if (!$notifications = $this->getNotifications($path)) {
if (empty($notifications)) {
return; return;
} }
// Push to a stack // Push to a stack
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
$setting = 'notifications.'. $notification->path . '.' . $notification->id . '.status';
$path = str_replace('/', '#', $notification->path); $path = str_replace('/', '#', $notification->path);
$message = str_replace('#path#', $path, $notification->message); $message = str_replace('#path#', $path, $notification->message);
$message = str_replace('#token#', csrf_token(), $message); $message = str_replace('#token#', csrf_token(), $message);
$message = str_replace('#url#', url('/'), $message);
if (!setting('notifications.' . $notification->path . '.' . $notification->id . '.status', 1)) {
continue;
}
if (setting($setting, 1)) {
$view->getFactory()->startPush('content_content_start', $message); $view->getFactory()->startPush('content_content_start', $message);
} }
} }
} }
}

View File

@ -2,8 +2,8 @@
namespace App\Http\ViewComposers; namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Traits\Modules; use App\Traits\Modules;
use Illuminate\View\View;
use Route; use Route;
class Suggestions class Suggestions

View File

@ -608,7 +608,7 @@ trait Modules
$data = []; $data = [];
if (!$notifications = static::getResponse('GET', 'apps/notifications')) { if (!$notifications = static::getResponseData('GET', 'apps/notifications')) {
return $data; return $data;
} }