NotificationController.php
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php namespace App\Http\Controllers;
use Auth;
use App\Models\Notification;
class NotificationController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
$notifications=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->orderBy('created_at')->get();
return view('layout.module.notification.index',array("notifications"=>$notifications));
}
public function create()
{
//
}
public function store()
{
//
}
public function show($id)
{
if($id=="topbar")
{
$this->checkLiveRooms();
$notifications=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->orderBy('created_at','desc')->take(10)->get();
$count=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->count();
$data=array();
foreach($notifications as $notification)
{
$data[]=array("sign"=>"+",
"type"=>$notification->type,
"text"=>$notification->data,
"tstr"=>date("d-M H:i",strtotime($notification->created_at)));
}
return view('layout.topbar.notification',array("notifications"=>$data,"notificationscount"=>$count));
}
}
public function edit($id)
{
//
}
public function update($id)
{
//
}
public function destroy($id)
{
if($id=="clearall")
{
Notification::where("to","=",Auth::user()->username)->where("status","=","New")->update(array('status' => 'Archive'));
return view('layout.module.notification.index',array("notifications"=>array(),'displaymsg'=>array("type"=>"success","text"=>"All Notifications Cleared")));
}
}
public function dashboard()
{
//echo "OK";
}
}