0; $i--) { $total += floor($i / 2); // * Pourcentage active. $pActive = $active + ($i * 100 / 365) / 100 - 0.2; $pActive = $pActive < 0.3 ? 0.3 : $pActive; $pInactive = 1 - $pActive; // * Pourcentage nouveau. $pNew = $new; $pOld = 1 - $pNew; $brandStat = new BrandStat([ 'active' => \floor($total * $pActive), 'inactive' => \ceil($total * $pInactive), 'old_accounts' => \ceil($total * $pOld), 'new_accounts' => \floor($total * $pNew), 'total_accounts' => $total, // 15% optin 'total_opt_in' => ceil($total * 0.15) ]); $brandStat->brand()->associate($brand); $brandStat->created_at = $startDay; $brandStat->saveOrFail(); $startDay = $startDay->subDay(); }//end for }//end foreach } }