mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Fix incoming favourites count
This commit is contained in:
parent
e89de763d5
commit
7fb5e14f4c
1 changed files with 11 additions and 3 deletions
14
user.php
14
user.php
|
@ -3,6 +3,7 @@ define('IN_PONEPASTE', 1);
|
||||||
require_once('includes/common.php');
|
require_once('includes/common.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use PonePaste\Models\User;
|
use PonePaste\Models\User;
|
||||||
use PonePaste\Models\Paste;
|
use PonePaste\Models\Paste;
|
||||||
|
|
||||||
|
@ -27,9 +28,16 @@ if (!$profile_info) {
|
||||||
|
|
||||||
$p_title = $profile_username . "'s Public Pastes";
|
$p_title = $profile_username . "'s Public Pastes";
|
||||||
|
|
||||||
// FIXME: This should be incoming faves
|
// There has to be a way to do the sum in SQL rather than PHP, but I can't figure out ho to do it in Eloquent.
|
||||||
//$total_pfav = Paste::where('user_id', $profile_info->id)->sum('faves');
|
$total_pfav = array_sum(
|
||||||
$total_pfav = $profile_info->favourites->count();
|
array_column(
|
||||||
|
Paste::select('id')
|
||||||
|
->where('user_id', $profile_info->id)
|
||||||
|
->withCount('favouriters')
|
||||||
|
->get()->toArray(),
|
||||||
|
'favouriters_count'
|
||||||
|
)
|
||||||
|
);
|
||||||
$total_yfav = $profile_info->favourites->count();
|
$total_yfav = $profile_info->favourites->count();
|
||||||
|
|
||||||
// Badges
|
// Badges
|
||||||
|
|
Loading…
Add table
Reference in a new issue