I Hope Every one doing well. I am trying to calculate percentage price level by level. Here is code
public function RankBelt(){
$payout=OrdersProduct::where(['user_type'=>'distributor'])->get();
foreach ($payout as $key=>$payoutdata) {
$total=$payoutdata->product_price;
}
echo "</br>";
$NumberFour=12;
//Commented Code will be Work code is perfectoly for Login distributor
//$referrals=auth()->user()->referrals()->count();
$users = User::withCount('referrals')->get();
//echo "<pre>";print_r(json_decode(json_encode($users)));
foreach ($users as $user) {
$referrals=$user->referrals_count."</br>";
if ($referrals==0) {
echo $payoutAmount= number_format(( 12*$total/100),2)."</br>";
}
if($referrals==1){
$referrals;
echo $payoutAmount= number_format(( 3.5*$total/100),2)."</br>";
}
if ($referrals==2) {
echo $payoutAmount= number_format(( 6*$total/100),2)."</br>";
}
if($referrals==3){
echo $payoutAmount= number_format(( 4.5*$total/100),2)."</br>";
}
}
die();
This code is Working perfect .I am Getting all value step by step.But I have new condition . step1:I Am trying to add new condition if referrals is 1 and total price is $900 then referrel one have 3.5$ deduction. step: $referrals==2 and then condition will be run .
$referrals==1 for 4.0% and $referrals==3%.
Please let me know If you need more Description. I know this is little bit difficult to undersatnd .I will try my best.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2nOObTe
via IFTTT
Aucun commentaire:
Enregistrer un commentaire