/** * Overwrite the handicap of a user */ public function setHandicap() { $user = OAuth::user(); $user->handicap = Request::get('handicap'); if ($user->save()) { return response()->json(null, 200); } else { return response()->json(['error' => 'handicap_update_failed', 'error_details' => 'Je dieetwensen konden niet worden opgeslagen'], 500); } }
/** * Wrap the content provided in the default template * @param View $view the View file to provide */ protected function setPageContent(\Illuminate\View\View $view) { return view($this->layout, ['content' => $view, 'javascript' => $this->loadControllerJavascript(), 'user' => OAuth::user()]); }
/** * Unsubscribe a user from a meal * @return JSON */ public function afmelden() { // Find the meal $meal = Meal::find((int) Request::input('meal_id')); if (!$meal) { return response()->json(['error' => 'meal_not_found', 'error_details' => 'De maaltijd bestaat niet'], 404); } // Check if the meal is still open if (!$meal->open_for_registrations()) { return response()->json(['error' => 'meal_deadline_expired', 'error_details' => 'De aanmeldingsdeadline is verstreken'], 400); } // Find the registration data $user = OAuth::user(); $registration = $user->registrationFor($meal); if (!$registration) { return response()->json(['error' => 'no_registration', 'error_details' => 'Je bent niet aangemeld voor deze maaltijd'], 404); } // Destroy the registration $id = $registration->id; $name = $registration->name; $registration->delete(); \Log::info("Afgemeld {$registration->name} (ID: {$registration->id}) voor {$meal} (ID: {$meal->id}) door {$user->name} (ID: {$user->id})"); return response(null, 200); }
<?php $meal = App\Models\Meal::today()->first(); $user = \App\Http\Helpers\OAuth::user(); if (!$meal || !$user) { return; } if ($meal && !$meal->open_for_registrations() && $user->registeredFor($meal)) { ?> <div class="notification success"> <img src="/images/tick.png" alt=""> Ja, je bent aangemeld voor vandaag. </div> <?php }