|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Table;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use MightyPork\Utils\Utils;
|
|
|
|
|
|
|
|
class DashController extends Controller
|
|
|
|
{
|
|
|
|
public function view(Request $request)
|
|
|
|
{
|
|
|
|
$dismiss = false;
|
|
|
|
if ($request->has('dismiss-greeter')) {
|
|
|
|
$dismiss = Utils::parseBool01($request->get('dismiss-greeter'));
|
|
|
|
\Cookie::queue('dismiss-greeter', $dismiss, 24*60*365*10);
|
|
|
|
return back();
|
|
|
|
}
|
|
|
|
|
|
|
|
$users = User::orderBy('updated_at', 'desc')
|
|
|
|
->withCount(['tables'])
|
|
|
|
->paginate(15, ['id', 'title', 'name', 'tables_count'], 'pageu');
|
|
|
|
|
|
|
|
// TODO visit counting
|
|
|
|
$tables = Table::forList()
|
|
|
|
->orderBy('visits', 'desc')
|
|
|
|
->paginate(10, ['*'], 'paget');
|
|
|
|
|
|
|
|
$showGreeter = !$dismiss && !$request->cookie('dismiss-greeter', false);
|
|
|
|
|
|
|
|
return view('welcome', compact('users', 'tables', 'showGreeter'));
|
|
|
|
}
|
|
|
|
}
|