Example #1
0
 /**
  * [fillDatabase description]
  * @return [type] [description]
  */
 public function fillDatabase()
 {
     $blacklist = array(7, 8);
     // Svartlistade månader då csn inte betalas ut
     $lastDBdate = PayDate::orderBy('date', 'desc')->first();
     $year = date('Y', strtotime($lastDBdate->date));
     $yearNow = date('Y');
     if ((int) $year - (int) $yearNow > 3) {
         // Du får bara lägga in i databasen för 3 år framåt
         return redirect('admin/cp');
     } else {
         $k = (int) date('m', strtotime($lastDBdate->date));
         if ((int) date('m', strtotime($lastDBdate->date)) == 12) {
             $year = (string) ((int) $year + 1);
             $k = 1;
         }
         for ($i = $k; $i <= 12; $i++) {
             if (!in_array($i, $blacklist)) {
                 $pd = new PayDate();
                 if ($i < 10) {
                     $m = '0' . $i;
                 } else {
                     $m = '' . $i;
                 }
                 $pd->date = date('Y-m-d', $this->generateFastPayDay($year, $m, '25'));
                 $pd->save();
             }
         }
         return redirect('admin/cp');
     }
 }
Example #2
0
 /**
  * [addDate description]
  */
 public function postAddDate(Request $request)
 {
     $paydate = new PayDate();
     $paydate->date = $request->date;
     $paydate->save();
     return redirect('admin/cp');
 }