Skip to content

Commit d37d29f

Browse files
committed
second 25/25/2017
1 parent 94efb5f commit d37d29f

File tree

966 files changed

+223801
-125637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

966 files changed

+223801
-125637
lines changed

app/Http/Controllers/BaseController.php

+42-2
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44

55
use App\Models\Post;
66
use App\User;
7+
use Cmgmyr\Messenger\Models\Thread;
78
use Illuminate\Support\Facades\Auth;
89
use Illuminate\Http\Request;
910
use Illuminate\Support\Facades\Response;
1011
use Kim\Activity\Activity;
1112
use Musonza\Chat\Chat;
1213
use Musonza\Chat\Conversations\Conversation;
14+
use Illuminate\Contracts\View\Factory as ViewFactory;
1315

1416
class BaseController extends Controller
1517
{
18+
protected $views;
1619
/**
1720
* BaseController constructor.
1821
*/
19-
public function __construct()
22+
public function __construct(ViewFactory $views)
2023
{
2124
$this->middleware('auth');
25+
$this->views = $views;
2226
}
2327

2428
/** sugestion list users randed
@@ -46,13 +50,48 @@ function most_recent_activity()
4650
}
4751
}
4852

53+
public function loadMessage($userId)
54+
{
55+
// $conversation = [];
56+
$currentUserId = Auth::user()->id;
57+
$threads = Thread::Between([$currentUserId, $userId])->latest('created_at')->get();
58+
// dd($threads);
59+
if ($threads)
60+
{
61+
foreach ($threads as $key => $thread) {
62+
$thread->unread = $thread->isUnread($currentUserId);
63+
64+
$thread->lastMessage = $thread->latestMessage;
65+
66+
$participants = $thread->participants()->get();
67+
68+
foreach ($participants as $key => $participant) {
69+
if ($participant->user->id != Auth::user()->id) {
70+
$thread->user = $participant->user;
71+
break;
72+
}
73+
}
74+
$thread->conversationMessages = $thread->messages()->orderBy('created_at', 'ASC')->latest()->with('user')->paginate(10);
75+
76+
foreach ($threads as $cov)
77+
{
78+
$threads->messages = $cov->messages;
79+
}
80+
}
81+
}
82+
// dd($threads);
83+
//return $threads = collect($conversation);
84+
return $this->views->make('pages.message.chat', compact('threads'))->render();
85+
}
86+
4987
/** from Highdeas And kim
5088
* @return \Illuminate\Support\Collection
5189
*/
5290
public function OnlineFriends()
5391
{
5492
$users = [];
5593
$user = Auth::user();
94+
5695
// $activities = $this->most_recent_activity();
5796
foreach($user->mostRecentOnline() as $online_user)
5897
{
@@ -66,8 +105,9 @@ public function OnlineFriends()
66105

67106
}
68107

108+
$onlineFriends = collect($users);
69109

70-
return collect($users);
110+
return $this->views->make('pages.partials.online_user', compact('onlineFriends'))->render();
71111
}
72112

73113
// public function getPosts()

app/Http/Controllers/FriendController.php

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
class FriendController extends BaseController
1212
{
13-
/**
14-
* @var ViewFactory
15-
*/
16-
private $views;
1713
/**
1814
* Create a new controller instance.
1915
*

app/Http/Controllers/HomeController.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
class HomeController extends BaseController
2222
{
2323

24-
private $views;
2524
public function __construct(ViewFac $views)
2625
{
27-
parent::__construct();
26+
parent::__construct($views);
2827
$this->views = $views;
2928
}
3029

0 commit comments

Comments
 (0)