Exemplo n.º 1
0
 public function run()
 {
     DB::table('days')->delete();
     $dt = Carbon::today()->subMonth(2);
     $startDay = Day::createDay($dt);
     for ($i = 0; $i < 700; $i++) {
         $this->day->onNextEmptyDate();
     }
 }
Exemplo n.º 2
0
 /**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 protected function setupLayout()
 {
     if (!is_null($this->layout)) {
         $this->layout = View::make($this->layout);
     }
     $currentUser = Auth::user();
     if (Auth::user()) {
         $currentUser->availabilities()->get()->sortByDesc(function ($avail) {
             return $avail->days()->first()['date'];
         });
     }
     View::share('currentUser', $currentUser);
     View::share('signedIn', Auth::user());
     View::share('allDays', Day::all());
 }
Exemplo n.º 3
0
 public function getCalendarMonthViewOfYearAndMonth($yearInput, $monthInput)
 {
     $dt = Carbon::parse($monthInput . '/01/' . $yearInput);
     $month = $dt->month;
     $year = strval($dt->year);
     $oneMonthViewOfDaysWithTelomeres = Day::oneMonthViewOfDaysWithTelomeres($month, $year);
     if ($month == 12) {
         $nextMonth = 1;
         $yearNext = $year + 1;
     } else {
         $nextMonth = $month + 1;
         $yearNext = $year;
     }
     if ($month == 1) {
         $previousMonth = 12;
         $yearPrevious = $year - 1;
     } else {
         $previousMonth = $month - 1;
         $yearPrevious = $year;
     }
     return View::make('api.days.month', compact(['oneMonthViewOfDaysWithTelomeres', 'nextMonth', 'previousMonth', 'year', 'yearNext', 'yearPrevious']));
 }
 public function create()
 {
     $locations = Location::all();
     $dt = Carbon::today();
     $month = $dt->month;
     $year = $dt->year;
     $oneMonthViewOfDaysWithTelomeres = Day::oneMonthViewOfDaysWithTelomeres($month, $year);
     if ($month == 12) {
         $nextMonth = 1;
         $yearNext = $year + 1;
     } else {
         $nextMonth = $month + 1;
         $yearNext = $year;
     }
     if ($month == 1) {
         $previousMonth = 12;
         $yearPrevious = $year - 1;
     } else {
         $previousMonth = $month - 1;
         $yearPrevious = $year;
     }
     $recurringAvailabilities = RecurringAvailability::where('advisor_id', Auth::user()->id)->get();
     return View::make('user.availabilities.create', compact(['oneMonthViewOfDaysWithTelomeres', 'nextMonth', 'previousMonth', 'year', 'yearNext', 'yearPrevious', 'locations', 'recurringAvailabilities']));
 }
Exemplo n.º 5
0
 public function indexDay($year, $month, $day)
 {
     $theDay = Day::findDay($year, $month, $day);
     return View::make('days.single', compact(['theDay']));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $recurringAvailabilities = RecurringAvailability::all();
     $today = Day::where('date', Carbon::today())->first();
     $daysInNextTwoWeeks = Day::whereBetween('id', [$today->id, (int) $today->id + 14])->lists('date');
     $advisors = Advisor::all();
     foreach ($advisors as $advisor) {
         if ($advisor->recurringAvailabilities()->count() == 0) {
             continue;
         }
         $availabilitiesInNextTwoWeeks = [];
         foreach ($advisor->availabilities()->get() as $avail) {
             if (in_array($avail->days()->first()->date, $daysInNextTwoWeeks)) {
                 if (count(explode(':', $avail->days()->first()->pivot->time)) == 1) {
                     if (explode(' ', $avail->days()->first()->pivot->time)[1] == 'AM') {
                         if (explode(' ', $avail->days()->first()->pivot->time)[0] == '12') {
                             $time = 0;
                         } else {
                             $time = (int) explode(' ', $avail->days()->first()->pivot->time)[0];
                         }
                     } else {
                         if (explode(' ', $avail->days()->first()->pivot->time)[0] == '12') {
                             $time = (int) explode(' ', $avail->days()->first()->pivot->time)[0];
                         } else {
                             $time = (int) explode(' ', $avail->days()->first()->pivot->time)[0] + 12;
                         }
                     }
                 } else {
                     if (explode(' ', explode(':', $avail->days()->first()->pivot->time)[1])[1] == 'AM') {
                         if (explode(':', $avail->days()->first()->pivot->time)[0] == '12') {
                             $time = 0;
                         } else {
                             $time = (int) explode(':', $avail->days()->first()->pivot->time)[0];
                         }
                     } else {
                         if (explode(':', $avail->days()->first()->pivot->time)[0] == '12') {
                             $time = (int) explode(':', $avail->days()->first()->pivot->time)[0];
                         } else {
                             $time = (int) explode(':', $avail->days()->first()->pivot->time)[0] + 12;
                         }
                     }
                 }
                 $availabilitiesInNextTwoWeeks[] = ['date' => $avail->days()->first()->date, 'time' => $time];
             }
         }
         $recurringAvailabilitiesInNextTwoWeeks = [];
         foreach ($advisor->recurringAvailabilities()->get() as $recurAvail) {
             $difference = $recurAvail->day_of_week - Carbon::parse($today->date)->dayOfWeek;
             $this->info($difference);
             $dayOfWeekOfRecurAvail = Day::find($today->id + $difference);
             $nextWeeksDay = Day::find($today->id + $difference + 7);
             $timeOfRecurAvail = $recurAvail->time;
             if ($this->in_array_r([$dayOfWeekOfRecurAvail->date, $recurAvail->time], $availabilitiesInNextTwoWeeks)) {
                 echo 'intersection of RecurAvail ID ' . $recurAvail->id . ' at date ' . $dayOfWeekOfRecurAvail->date . "\n";
             } else {
                 // Create it for this Week
                 if ($difference > 0) {
                     Availability::createRecurringAvailability($timeOfRecurAvail, $dayOfWeekOfRecurAvail->id, $advisor->id, Service::where('name', '25 Minute Free Consultation')->first()->id, $recurAvail->location_id);
                 }
                 if (!$this->in_array_r([$nextWeeksDay->date, $recurAvail->time], $availabilitiesInNextTwoWeeks)) {
                     // Create it for next week
                     Availability::createRecurringAvailability($timeOfRecurAvail, (int) $dayOfWeekOfRecurAvail->id + 7, $advisor->id, Service::where('name', '25 Minute Free Consultation')->first()->id, $recurAvail->location_id);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 public static function getAllDaysInSelectedMonth($month, $year)
 {
     $daysInMonth = Day::where(DB::raw('MONTH(date)'), '=', date($month))->where(DB::raw('YEAR(date)'), '=', date($year))->get();
     return $daysInMonth;
 }