Example #1
0
 public function createAvailability($data, $day_id, $advisor_id, $service_id)
 {
     $times = [$data[0], $data[0] . ':30'];
     foreach ($times as $time) {
         $availability = new Availability();
         $availability->save();
         switch ($data[2]) {
             case 'wsl':
                 $data[2] = Location::where('name', 'Walnut St. Labs')->first()->id;
                 break;
             case 'ice':
                 $data[2] = Location::where('name', 'ICE')->first()->id;
                 break;
             case 'evolve':
                 $data[2] = Location::where('name', 'Evolve IP')->first()->id;
                 break;
             case 'nextfab':
                 $data[2] = Location::where('name', 'NextFab')->first()->id;
                 break;
             case 'remote':
                 $data[2] = Location::where('name', 'Remote')->first()->id;
                 break;
         }
         $availability->locations()->attach($data[2]);
         $availability->advisors()->attach($advisor_id);
         $availability->services()->attach($service_id);
         $availability->days()->attach($day_id, ['time' => $time . ' ' . $data[1]]);
     }
 }
 public function __construct(Service $service)
 {
     $this->beforeFilter('expired-session-check');
     $this->service = $service;
     $servicesNotContainedByAdvisor = $this->service->servicesNotContainedByAdvisor(Auth::user()->id);
     $servicesContainedByAdvisor = $this->service->servicesContainedByAdvisor(Auth::user()->id);
     $locationFormPopulator = Location::lists('name', 'id');
     View::share('servicesNotContainedByAdvisor', $servicesNotContainedByAdvisor);
     View::share('servicesContainedByAdvisor', $servicesContainedByAdvisor);
     view::share('locationFormPopulator', $locationFormPopulator);
 }
 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']));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $location = Location::find($id);
     return View::make('locations.edit', compact(['location']));
 }