|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Notification\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Modules\Core\Http\Controllers\Admin\AdminBaseController; |
|
6
|
|
|
use Modules\Notification\Entities\Notification; |
|
7
|
|
|
use Modules\Notification\Repositories\NotificationRepository; |
|
8
|
|
|
use Modules\User\Contracts\Authentication; |
|
9
|
|
|
|
|
10
|
|
|
class NotificationsController extends AdminBaseController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var NotificationRepository |
|
14
|
|
|
*/ |
|
15
|
|
|
private $notification; |
|
16
|
|
|
/** |
|
17
|
|
|
* @var Authentication |
|
18
|
|
|
*/ |
|
19
|
|
|
private $auth; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct(NotificationRepository $notification, Authentication $auth) |
|
22
|
|
|
{ |
|
23
|
|
|
parent::__construct(); |
|
24
|
|
|
|
|
25
|
|
|
$this->notification = $notification; |
|
26
|
|
|
$this->auth = $auth; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function index() |
|
30
|
|
|
{ |
|
31
|
|
|
$notifications = $this->notification->allForUser($this->auth->id()); |
|
32
|
|
|
|
|
33
|
|
|
return view('notification::admin.notifications.index', compact('notifications')); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Remove the specified resource from storage. |
|
38
|
|
|
* |
|
39
|
|
|
* @param Notification $notification |
|
40
|
|
|
* @return Response |
|
41
|
|
|
*/ |
|
42
|
|
|
public function destroy(Notification $notification) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->notification->destroy($notification); |
|
45
|
|
|
|
|
46
|
|
|
return redirect()->route('admin.notification.notification.index') |
|
47
|
|
|
->withSuccess(trans('core::core.messages.resource deleted', ['name' => 'Notification'])); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function destroyAll() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->notification->deleteAllForUser($this->auth->id()); |
|
53
|
|
|
|
|
54
|
|
|
return redirect()->route('admin.notification.notification.index') |
|
55
|
|
|
->withSuccess(trans('notification::messages.all notifications deleted')); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function markAllAsRead() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->notification->markAllAsReadForUser($this->auth->id()); |
|
61
|
|
|
|
|
62
|
|
|
return redirect()->route('admin.notification.notification.index') |
|
63
|
|
|
->withSuccess(trans('notification::messages.all notifications marked as read')); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|