Пример #1
0
 public function calenderNotification(Request $request)
 {
     $year = $request->get('year');
     $month = $request->get('month');
     if (!isset($year) && !isset($month)) {
         $year = date('Y');
         $month = date('m') - 1;
     }
     $notifications = Notification::whereBetween('will_be', $this->getYearsBetween($year, $month))->get();
     $dates = [];
     $info = [];
     //savinjson data in the format {22: {title: "", body: ""}}
     foreach ($notifications as $notification) {
         $day = intval(substr($notification->will_be, -2), 10);
         //convert 02 to 2
         $info[$day] = ['title' => $notification->title, 'body' => $notification->body];
         $dates[] = $day;
     }
     $info['dates'] = $dates;
     return $info;
 }