/** * 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); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //get all waiters $waiters = Waiter::all(); $data = []; $data['waiters'] = $waiters; return View('waiter.index')->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(); }