コード例 #1
0
ファイル: Alarm.php プロジェクト: OfficineDigitali/pendola
 public function reIterate()
 {
     if ($this->type->recurrence == 'once') {
         return;
     }
     $a = new Alarm();
     $a->type_id = $this->type_id;
     $a->entity_id = $this->entity_id;
     $a->author_id = Auth::user()->id;
     $a->owner_id = $this->owner_id;
     $a->notes = '';
     $a->closed = false;
     $a->closer_id = -1;
     $a->prev_id = $this->id;
     switch ($this->type->recurrence) {
         case 'daily':
             $future = '+1 day';
             break;
         case 'weekly':
             $future = '+1 week';
             break;
         case 'monthly':
             $future = '+1 month';
             break;
         case 'yearly':
             $future = '+1 year';
             break;
         case 'custom':
             $future = sprintf('+%s', $this->type->recurrence_details);
             break;
     }
     $a->date1 = date('Y-m-d', strtotime($this->date1 . $future));
     if ($this->type->type == 'interval') {
         $a->date2 = date('Y-m-d', strtotime($this->date2 . $future));
     }
     $a->save();
 }
コード例 #2
0
 public function store(Request $request)
 {
     $a = new Alarm();
     $a->type_id = $request->input('alarmtype');
     $a->entity_id = $request->input('entity');
     $a->author_id = Auth::user()->id;
     $a->owner_id = $request->input('owner_id');
     $a->date1 = $request->input('date1');
     $a->date2 = $request->input('date2', '');
     $a->notes = $request->input('notes');
     $a->closed = false;
     $a->closer_id = -1;
     $a->save();
     Session::flash('message', 'Nuova scadenza salvata correttamente');
     Session::flash('message_type', 'success');
     return redirect(url('/alarms'));
 }