public function run()
 {
     // TestDummy::times(20)->create('App\Post');
     DB::table('schedule')->delete();
     $user = User::take(2)->get();
     $shows = Show::all();
     for ($day = 0; $day <= 6; $day++) {
         for ($hour = 1; $hour <= 24; $hour++) {
             $idIndex = ($hour - 1) % 4 < 2 ? 0 : 1;
             $show = $shows->random();
             $slot = new TimeSlot(['show' => $show->id, 'dj' => $user[$idIndex]->id, 'day' => $day, 'hour' => $hour]);
             $slot->save();
         }
     }
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $timeslots = TimeSlot::with('djForTimeslot', 'showForTimeslot')->get();
     $shows = WeeklySchedule::mergeFromTimeSlots($timeslots);
     $showSlides = $shows->getShowsForSlideshow();
     $slides = Slides::forShows($showSlides);
     $events = Event::where('type', 'SLIDER')->where('date', '>=', Carbon::today('America/New_York'))->get();
     if (!$events->isEmpty()) {
         $slides->addEvent($events->random());
     }
     $view->with('slides', $slides);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request)
 {
     $input = $request->all();
     $timeslots = TimeSlot::all();
     foreach ($timeslots as $timeslot) {
         $dj = $input['dj_' . $timeslot->id];
         $show = $input['show_' . $timeslot->id];
         $timeslot->dj = $dj;
         $timeslot->show = $show;
         $timeslot->save();
     }
 }
Beispiel #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $timeslots = TimeSlot::where('dj', $id)->count();
     if ($timeslots > 0) {
         return redirect()->back()->with('error', 'Remove DJ from schedule before deleting.');
     }
     $dj = DJ::findOrFail($id);
     File::delete(public_path() . '/img/djs/' . $dj->picture);
     DJ::destroy($id);
     return redirect()->route('admin.djs.index')->with('success', 'DJ Deleted!');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function schedule()
 {
     $schedule = WeeklySchedule::mergeFromTimeSlots(TimeSlot::with('djForTimeslot', 'showForTimeslot')->get());
     return view('schedule.schedule')->withSchedule($schedule);
 }