/** * Bootstrap any application services. * * @return void */ public function boot() { $quizz = Quizz::where('actif', 1)->first(); if (!$quizz) { $backgroundColor = self::BACKGROUND_COLOR_DEFAULT; $btnColor = self::BTN_COLOR_DEFAULT; } else { $backgroundColor = $quizz->theme->color_nav; $btnColor = $quizz->theme->color_elements; } view()->share('backgroundColor', $backgroundColor); view()->share('btnColor', $btnColor); }
public function index() { $quizzs = Quizz::all(); $questions = Question::all(); $themes = Theme::all(); $users = User::all(); $actifQuizz = Quizz::where('actif', 1)->first(); if (!$actifQuizz) { $goodAnswerNbr = 0; $badAnswerNbr = 0; } else { $goodAnswerNbr = Score::where('quizz_id', $actifQuizz->id)->where('correct', true)->count(); $badAnswerNbr = Score::where('quizz_id', $actifQuizz->id)->where('correct', false)->count(); } return view('admin.dashboard.index', ['quizzs' => $quizzs, 'questions' => $questions, 'themes' => $themes, 'users' => $users, 'actifQuizz' => $actifQuizz, 'goodAnswerNbr' => $goodAnswerNbr, 'badAnswerNbr' => $badAnswerNbr]); }
/** * @return mixed */ public function getActif() { return Quizz::where('actif', 1)->first(); }