/** * Show the application dashboard to the user. * * @return Response */ public function index() { $series = Series::all(); // get lottery to display $time = date("Hi"); $next_draw_lottery = Lottery::where("draw_time", '>', $time)->orderBy("draw_time")->first(); if ($next_draw_lottery) { $next_draw_time = date_create_from_format("Hi", $next_draw_lottery->draw_time); $next_draw_time = $next_draw_time->format("h:i A"); } else { $next_draw_time = "--:--"; } $lottery = Lottery::where("draw_time", '<=', $time)->orderBy("draw_time", "desc")->first(); if ($lottery) { $date = date('Y-m-d'); $results = Result::where(array("date" => $date, 'lottery_id' => $lottery->id))->with('series')->get(); } // dd($results->first()->series->code); return view('home', compact('results', 'lottery', 'series', 'next_draw_time')); }
public function isInLottery() { return \App\Lottery::where('award_id', $this->id)->count() >= 1; }