/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $waiters = Waiter::all();
     $areas = Area::all();
     $today = Carbon::today('Europe/Brussels');
     $endDay = $today->copy()->addDay();
     $waiterAreas = WaiterArea::where('start_time', '>', $today)->where('end_time', '<', $endDay);
     $waiterAreasToday = $waiterAreas->get();
     //dd($waiterAreas->get());
     $workingAreas = $waiterAreas->groupBy('FK_waiter_id')->get();
     $workingWaiters = collect([]);
     foreach ($workingAreas as $waiterarea) {
         //var_dump($waiterarea->waiter);
         $workingWaiters->push($waiterarea->waiter);
     }
     foreach ($workingWaiters as $waiter) {
         $waiter->workingAreas = collect([]);
         foreach ($waiterAreasToday as $waiterarea) {
             if ($waiter->id == $waiterarea->FK_waiter_id) {
                 $waiter->workingAreas->push($waiterarea);
             }
         }
     }
     $data = [];
     $data['waiters'] = $waiters;
     $data['areas'] = $areas;
     $data['waiterAreas'] = $waiterAreas;
     $data['workingWaiters'] = $workingWaiters;
     return View('waiterArea.create')->with($data);
 }
 public function mailPlanning($id)
 {
     $waiters = Waiter::all();
     $planning = Planning::find($id);
     $waiters = $this->planningWaiters($waiters, $id, $planning);
     //mail to all waiters
     foreach ($waiters as $waiter) {
         Mail::send('emails.planning', ['user' => $waiter, 'waiters' => $waiters, 'planning' => $planning], function ($m) use($waiter) {
             $m->from(env('MAIL_FROM'), env('MAIL_NAME'));
             $m->to($waiter->email, $waiter->name)->subject('Your Reminder!');
         });
     }
     return redirect()->back();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //get waiter on id or throw exception
     $waiter = Waiter::findorfail($id);
     $waiter->softDelete();
     return redirect()->back()->withSuccess('ober verwijderd');
 }