title: change 1 year period to 30 days in laravel?
body: <p>i have my laravel project which works like this:</p>
  <p>system will calculate the profit per 1 year from start day of investment,
  and add credit to user balance. how to change 1 year period to <strong>30 days</strong> (<strong>or 1 month</strong>)?</p>
  <p>here is the code for 1 year bellow:</p>
  <pre><code>            public function boot()
              {
              View::composer('*', function($view){
              if (Auth::check()){
              $alert=Alerts::whereUser_id(Auth::user()-&gt;id)-&gt;orderBy('id', 'DESC')-&gt;get();
              $user=User::find(Auth::user()-&gt;id);
              $currency=Currency::whereStatus(1)-&gt;first();
              if(empty($user-&gt;image)){
                  $cast=&quot;react.jpg&quot;;
              }else{
                  $cast=$user-&gt;image;
              }
              $seen=Alerts::where('user_id', Auth::user()-&gt;id)-&gt;where('seen', 0)-&gt;get();
              $save=$data['save']=Save::where('user_id', Auth::user()-&gt;id)-&gt;get();
              $profit=$data['profit']=Profits::whereUser_id(Auth::user()-&gt;id)-&gt;orderBy('id', 'DESC')- 
              &gt;get();
              foreach($profit as $xpro){
                  $profits=Profits::whereId($xpro-&gt;id)-&gt;first();
                  $date1=date_create(Carbon::now());
                  $date2=date_create($xpro-&gt;date);
                  $date_diff=date_diff($date2, $date1);
                  $start_date=date_create($xpro-&gt;date);
                  date_add($start_date, date_interval_create_from_date_string('1 year'));
                  $ndate=date_format($start_date, &quot;Y-m-d H:i:s&quot;);   
                  $profits-&gt;end_date=$ndate;
                  $profits-&gt;save();
                  if (Carbon::now()&lt;$ndate){
                      $fdate=($xpro-&gt;plan-&gt;percent*$xpro-&gt;amount)/100 * (12*$date_diff- 
                   &gt;format('%R%a')/365);   
                      $profits-&gt;profit=$fdate;
                      $profits-&gt;status=1;
                      $profits-&gt;save();
                  }else{
                      $fdate=($xpro-&gt;plan-&gt;percent*$xpro-&gt;amount)/100 * 12;  
                      $profits-&gt;profit=$fdate;
                      $profits-&gt;save();
                      if($xpro-&gt;status==1){
                          $val1=$user-&gt;balance+$fdate;
                          $user-&gt;balance=$val1;
                          $user-&gt;save();   
                          $profits-&gt;status=2;
                          $profits-&gt;save();
                      }
                  }
              }
              foreach($save as $xsave){
                  $date1=strtotime(date('Y-m-d'));
                  $date2=strtotime($xsave-&gt;end_date);
                  if(($xsave-&gt;status==0 &amp;&amp; $date1&gt;$date2) || ($xsave-&gt;status==0 &amp;&amp; $date1==$date2)){
                      $save_amo=$user-&gt;balance+$xsave-&gt;amount;
                      $user-&gt;balance=$save_amo;
                      $user-&gt;save();
                      foreach ($save as $ss){
                          $ss-&gt;status=1;
                          $ss-&gt;save();  
                      }                   
                   } 
                  }
  </code></pre>