|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
namespace App;
|
|
namespace App;
|
|
|
|
|
|
-use Storage;
|
|
|
|
|
|
+use Auth, Storage;
|
|
use App\Util\Lexer\PrettyNumber;
|
|
use App\Util\Lexer\PrettyNumber;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
@@ -138,4 +138,35 @@ class Profile extends Model
|
|
{
|
|
{
|
|
return $this->statuses()->whereHas('media')->count();
|
|
return $this->statuses()->whereHas('media')->count();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function recommendFollowers()
|
|
|
|
+ {
|
|
|
|
+ $follows = $this->following()->pluck('followers.id');
|
|
|
|
+ $following = $this->following()
|
|
|
|
+ ->orderByRaw('rand()')
|
|
|
|
+ ->take(3)
|
|
|
|
+ ->pluck('following_id');
|
|
|
|
+ $following->push(Auth::id());
|
|
|
|
+ $following = Follower::whereNotIn('profile_id', $follows)
|
|
|
|
+ ->whereNotIn('following_id', $following)
|
|
|
|
+ ->whereNotIn('following_id', $follows)
|
|
|
|
+ ->whereIn('profile_id', $following)
|
|
|
|
+ ->orderByRaw('rand()')
|
|
|
|
+ ->limit(3)
|
|
|
|
+ ->pluck('following_id');
|
|
|
|
+ $recommended = [];
|
|
|
|
+ foreach($following as $follow) {
|
|
|
|
+ $recommended[] = Profile::findOrFail($follow);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $recommended;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function keyId()
|
|
|
|
+ {
|
|
|
|
+ if($this->remote_url) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ return $this->permalink('#main-key');
|
|
|
|
+ }
|
|
}
|
|
}
|