|
|
|
@ -20,71 +20,20 @@ class DashController extends Controller |
|
|
|
|
return back(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$defaultSort = 'last-updated'; |
|
|
|
|
|
|
|
|
|
$sort = \Input::get('tableSort', $defaultSort); |
|
|
|
|
|
|
|
|
|
$data['sortOptions'] = [ |
|
|
|
|
'most-visited' => 'Most Visited', |
|
|
|
|
'last-updated' => 'Last Updated', |
|
|
|
|
'most-updated' => 'Most Changed', |
|
|
|
|
// 'most-discussed' => 'Most Discussed', |
|
|
|
|
// 'most-liked' => 'Most Liked', |
|
|
|
|
'newest' => 'Newest', |
|
|
|
|
'oldest' => 'Oldest', |
|
|
|
|
'most-rows' => 'Longest', |
|
|
|
|
'least-rows' => 'Shortest', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if (!in_array($sort, array_keys($data['sortOptions']))) { |
|
|
|
|
$sort = $defaultSort; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data['tableSort'] = $sort; |
|
|
|
|
|
|
|
|
|
$data['users'] = User::orderBy('updated_at', 'desc') |
|
|
|
|
->withCount(['tables']) |
|
|
|
|
->paginate(10, ['id', 'title', 'name', 'tables_count'], 'userPage') |
|
|
|
|
->appends(\Input::except('userPage')); |
|
|
|
|
|
|
|
|
|
$tableQuery = Table::forList(); |
|
|
|
|
switch ($sort) { |
|
|
|
|
case 'most-visited': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('visits', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'last-updated': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('updated_at', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'most-updated': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('revisions_count', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'most-discussed': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('comments_count', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'most-liked': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('favourites_count', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'most-rows': |
|
|
|
|
$tableQuery = $tableQuery |
|
|
|
|
->join('revisions', 'revisions.id', '=', 'tables.revision_id') |
|
|
|
|
->orderBy('revisions.row_count', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'least-rows': |
|
|
|
|
$tableQuery = $tableQuery |
|
|
|
|
->join('revisions', 'revisions.id', '=', 'tables.revision_id') |
|
|
|
|
->orderBy('revisions.row_count', 'asc'); |
|
|
|
|
break; |
|
|
|
|
case 'newest': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('created_at', 'desc'); |
|
|
|
|
break; |
|
|
|
|
case 'oldest': |
|
|
|
|
$tableQuery = $tableQuery->orderBy('created_at', 'asc'); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
$sort = Table::resolveSortType(\Input::get('tableSort')); |
|
|
|
|
$data['sortOptions'] = Table::getSortOptions(); |
|
|
|
|
|
|
|
|
|
$data['tables'] = $tableQuery->paginate(10, ['*'], 'tablePage') |
|
|
|
|
$data['tables'] = Table::forList()->tableSort($sort) |
|
|
|
|
->paginate(10, ['*'], 'tablePage') |
|
|
|
|
->appends(\Input::except('tablePage')); |
|
|
|
|
|
|
|
|
|
$data['tableSort'] = $sort; |
|
|
|
|
|
|
|
|
|
$data['showGreeter'] = !$dismiss && !$request->cookie('dismiss-greeter', false); |
|
|
|
|
|
|
|
|
|
return view('welcome', $data); |
|
|
|
|