Cara menghitung persentase penyelesaian profil di Laravel
$maximumPoints = 100;
$profile = !empty($user->profile) ? 16.7 : 0;
$username = !empty($user->username) ? 16.7 : 0;
$zip_code = !empty($user->zip_code) ? 16.7 : 0;
$gender = !empty($user->gender) ? 16.7 : 0;
$aboutus = !empty($user->about_us) ? 16.7 : 0;
$sportDetail = (count($userSportCategory) > 0) ? 16.7 : 0;
$percentage = intval(($profile+$username+$zip_code+$gender+$sportDetail+$aboutus)*$maximumPoints/100);
$user['percentage'] = $percentage.'%';
Misty Mole