public dash and view counting
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user