52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Constellation;
|
|
use Illuminate\Http\Request;
|
|
use DB;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('home');
|
|
}
|
|
|
|
public function constellations(Request $request)
|
|
{
|
|
$dates = Constellation::groupBy('date')
|
|
->orderBy('date', 'DESC')
|
|
->get([
|
|
DB::raw('Date(created_at) as date')
|
|
])->pluck('date');
|
|
|
|
$queriedDate = $request->get('date');
|
|
if(!$queriedDate) {
|
|
$queriedDate = $dates->first();
|
|
}
|
|
|
|
$constellations = Constellation::whereDate('created_at', $queriedDate)->get();
|
|
|
|
return view('constellations')->with([
|
|
'dates' => $dates,
|
|
'queriedDate' => $queriedDate,
|
|
'constellations' => $constellations
|
|
]);
|
|
}
|
|
}
|