add Longest and Shortest filters
This commit is contained in:
@@ -30,6 +30,8 @@ class DashController extends Controller
|
||||
// 'most-liked' => 'Most Liked',
|
||||
'newest' => 'Newest',
|
||||
'oldest' => 'Oldest',
|
||||
'most-rows' => 'Longest',
|
||||
'least-rows' => 'Shortest',
|
||||
];
|
||||
|
||||
$data['users'] = User::orderBy('updated_at', 'desc')
|
||||
@@ -54,6 +56,16 @@ class DashController extends Controller
|
||||
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;
|
||||
|
||||
@@ -188,7 +188,8 @@ class Table extends BaseModel
|
||||
|
||||
public function scopeForList(Builder $query)
|
||||
{
|
||||
return $query->with('revision:id,row_count')->with('owner:id,name,title')
|
||||
return $query->with('revision:id,row_count')
|
||||
->with('owner:id,name,title')
|
||||
->withCount(['favourites', 'forks', 'revisions', 'proposals', 'comments']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user