public dash and view counting

This commit is contained in:
2018-07-29 11:52:29 +02:00
parent f77b1789fa
commit a79b5ae7d8
37 changed files with 415 additions and 663 deletions
+12 -1
View File
@@ -20,7 +20,10 @@ class TableController extends Controller
]);
/** @var Table $tableModel */
$tableModel = $user->tables()->where('name', $table)->first();
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments'])
->where('name', $table)->first();
if ($tableModel === null) abort(404, "No such table.");
// make it possible to show other revisions
if ($input->has('rev')) {
@@ -31,6 +34,14 @@ class TableController extends Controller
$revision = $tableModel->revision;
}
$cookieName = "view!$user->name!$table";
if (!$request->cookie($cookieName, false)) {
$tableModel->countVisit();
\Cookie::queue($cookieName, true, 86400);
}
return view('table.view', [
'table' => $tableModel,
'revision' => $revision,