|
|
@@ -93,11 +93,45 @@ Route::middleware('auth:sanctum')->post('/get_blog/list', function (Request $req
|
|
|
LEFT JOIN (
|
|
|
SELECT [blogId],COUNT(*) AS total
|
|
|
FROM [laravel_kevin].[dbo].[comments]
|
|
|
- GROUP BY [blogId]) as t ON [blogs].[id] = [t].[blogId]");
|
|
|
+ GROUP BY [blogId]) as t ON [blogs].[id] = [t].[blogId]
|
|
|
+ ORDER BY blogs.id DESC");
|
|
|
|
|
|
return $blogList;
|
|
|
});
|
|
|
|
|
|
+Route::middleware('auth:sanctum')->post('/get_blog/list/perpage', function (Request $request) {
|
|
|
+ $request->validate([
|
|
|
+ 'offset' => 'required',
|
|
|
+ 'rows' => 'required',
|
|
|
+ ]);
|
|
|
+ $blogList = DB::select("SELECT
|
|
|
+ blogs.id,
|
|
|
+ title,
|
|
|
+ content AS excerpt,
|
|
|
+ tags, users.id AS userId,
|
|
|
+ users.name AS userFullName,
|
|
|
+ blogs.created_at AS blogPosted,
|
|
|
+ t.total AS comment
|
|
|
+ FROM [laravel_kevin].[dbo].[blogs]
|
|
|
+ RIGHT JOIN [dbo].[users] ON [blogs].[writer] = [users].[id]
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT [blogId],COUNT(*) AS total
|
|
|
+ FROM [laravel_kevin].[dbo].[comments]
|
|
|
+ GROUP BY [blogId]) as t ON [blogs].[id] = [t].[blogId]
|
|
|
+ ORDER BY blogs.id DESC
|
|
|
+ OFFSET " . $request->offset . " ROW
|
|
|
+ FETCH NEXT " . $request->rows . " ROWS ONLY");
|
|
|
+
|
|
|
+ return $blogList;
|
|
|
+});
|
|
|
+
|
|
|
+Route::middleware('auth:sanctum')->post('/get_blog/list/total', function (Request $request) {
|
|
|
+ $blogList = DB::select("SELECT COUNT(*) AS total
|
|
|
+ FROM [laravel_kevin].[dbo].[blogs]");
|
|
|
+
|
|
|
+ return $blogList[0]->total;
|
|
|
+});
|
|
|
+
|
|
|
Route::middleware('auth:sanctum')->post('/get_blog/detail', function (Request $request) {
|
|
|
$request->validate([
|
|
|
'blogId' => 'required',
|
|
|
@@ -127,9 +161,14 @@ Route::middleware('auth:sanctum')->post('/get_blog/detail', function (Request $r
|
|
|
});
|
|
|
|
|
|
Route::middleware('auth:sanctum')->post('/get_blog/sidebar', function (Request $request) {
|
|
|
- $recentPosts = DB::select("SELECT blogs.id, title, blogs.created_at AS createdTime
|
|
|
+ $recentPosts = DB::select("SELECT TOP(4) blogs.id, title, blogs.created_at AS createdTime, t.total AS comments
|
|
|
FROM [laravel_kevin].[dbo].[blogs]
|
|
|
- RIGHT JOIN [dbo].[users] ON [blogs].[writer] = [users].[id]");
|
|
|
+ RIGHT JOIN [dbo].[users] ON [blogs].[writer] = [users].[id]
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT [blogId],COUNT(*) AS total
|
|
|
+ FROM [laravel_kevin].[dbo].[comments]
|
|
|
+ GROUP BY [blogId]) as t ON [blogs].[id] = [t].[blogId]
|
|
|
+ ORDER BY comments DESC");
|
|
|
|
|
|
$categories = [
|
|
|
['category' => 'Fashion', 'icon' => 'WatchIcon'],
|