Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

I recommend you using redis . When one user have more and more friends, your mysql table will be very very big. In that case if you query friends information from mysql, it is not a good idea. You query will be very slow.

In this case, you'd better using some Cache Tools to improve your application, such as Memcache Redis ..

Last updated 2 years ago.
0

But I need to find a way to grap the status updates from my friends. I will work on the rest later.

Last updated 2 years ago.
0

I tried this but is not working

public function getStatusUpdatesFromFriends() {
	$user = \Auth::user();

	$friend_list    = $user->friends()->lists('id');
	$revFriends_list = $user->revFriends()->lists('id');

	$friends = array_unique(array_merge($friend_list, $revFriends_list));

	$friends[]  = $user->id; // To show my own updates
	// dd($friends);

	$statuses = $this->model->with(array('users' => function($query) use($friends) {
		$query->whereIn('user_id', $friends);
	}))->get();

	dd($statuses);
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

eriktisme eriktisme Joined 31 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.