1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class HomeController extends BaseController { |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
|-------------------------------------------------------------------------- |
7
|
|
|
| Default Home Controller |
8
|
|
|
|-------------------------------------------------------------------------- |
9
|
|
|
| |
10
|
|
|
| You may wish to use controllers instead of, or in addition to, Closure |
11
|
|
|
| based routes. That's great! Here is an example controller method to |
12
|
|
|
| get you started. To route to this controller, just add the route: |
13
|
|
|
| |
14
|
|
|
| Route::get('/', 'HomeController@showWelcome'); |
15
|
|
|
| |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
public function showWelcome() |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
if (Auth::user()) { |
22
|
|
|
|
23
|
|
|
// $email = Auth::user()->email; |
24
|
|
|
$userDetails = DB::table('users')->select('*')->where('id', Auth::user()->id)->get(); |
25
|
|
|
foreach ($userDetails as $key => $value) { |
26
|
|
|
$userDetailsArray = array(); |
|
|
|
|
27
|
|
|
$userDetailsArray = $value; |
28
|
|
|
} |
29
|
|
|
// print_r($userDetailsArray); |
30
|
|
|
|
31
|
|
|
// $data['userDetailsArray']=$userDetailsArray; |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
/* |
35
|
|
|
* get notofications,task notifications,global notifications ... |
36
|
|
|
*/ |
37
|
|
|
$countUnreadMessages = DB::table('personal_conversations') |
38
|
|
|
->select(DB::raw('count(read_status) as unread_count')) |
39
|
|
|
|
40
|
|
|
->where('read_status','=',1) |
41
|
|
|
->where('to_user_id','=',Auth::user()->id)->first(); |
42
|
|
|
|
43
|
|
|
$countUnreadGeneralMessages = DB::table('team_conversations_read_status') |
44
|
|
|
->select(DB::raw('count(read_status) as unread_count')) |
45
|
|
|
|
46
|
|
|
->where('read_status','=',1) |
47
|
|
|
->where('user_id','=',Auth::user()->id)->first(); |
48
|
|
|
|
49
|
|
|
$countUnreadJoinMessages = DB::table('invitation_notification') |
50
|
|
|
->select(DB::raw('count(read_status) as unread_count')) |
51
|
|
|
|
52
|
|
|
->where('read_status','=',1) |
53
|
|
|
|
54
|
|
|
->where('invitation_notification.new_user', '!=', Auth::user()->id) |
55
|
|
|
->where('team_user','=',Auth::user()->id)->first(); |
56
|
|
|
/* |
57
|
|
|
* pass each notifcation count in array |
58
|
|
|
*/ |
59
|
|
|
|
60
|
|
|
$data=array( |
61
|
|
|
|
62
|
|
|
"unreadMessageCount"=>$countUnreadMessages["unread_count"], |
63
|
|
|
"userDetailsArray"=>$userDetailsArray, |
|
|
|
|
64
|
|
|
"unreadGeneralMessageCount"=>$countUnreadGeneralMessages["unread_count"], |
65
|
|
|
"unreadJoinMessageCount"=>$countUnreadJoinMessages["unread_count"], |
66
|
|
|
|
67
|
|
|
); |
68
|
|
|
return View::make('templates/home')->with("data",$data); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|