浏览代码

Similarly, load recent comments on author pages

axkuhta 1 年之前
父节点
当前提交
0316d26a60
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app/Http/Controllers/AuthorController.php

+ 6 - 1
app/Http/Controllers/AuthorController.php

@@ -17,7 +17,12 @@ class AuthorController extends Controller {
 	}
 
 	function view(Author $author) {
-		return view("author", ["author" => $author->load(["books", "comments"])]);
+		return view("author", [
+			"author" => $author->load([
+				"books" => function($query) {},
+				"comments" => function($query) { $query->recent(); }
+			])
+		]);
 	}
 
 	function edit(Author $author) {