Skip to content

Commit 095bb96

Browse files
author
hui-ho
committed
优化网站列表渲染,填充预设网站
1 parent 67b9037 commit 095bb96

File tree

236 files changed

+736
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+736
-34
lines changed

app/Category.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class Category extends Model
1010
{
1111
use ModelTree, AdminBuilder;
1212

13+
public function children()
14+
{
15+
return $this->hasMany(static::class, 'parent_id');
16+
}
17+
1318
public function sites()
1419
{
1520
return $this->hasMany(Site::class);

app/Http/Controllers/HomeController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class HomeController extends Controller
1010
public function index()
1111
{
1212
return view('index', [
13-
'categories' => Category::getWithArray(),
14-
'sites' => Category::where('parent_id', '<>', 0)->get(),
13+
'categories' => Category::with('children', 'sites')->get(),
1514
]);
1615
}
1716
}

database/seeds/SitesTableSeeder.php

Lines changed: 693 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)