diff --git a/app/Models/Topic.php b/app/Models/Topic.php index a1768e914..d0e8bb2bf 100644 --- a/app/Models/Topic.php +++ b/app/Models/Topic.php @@ -7,6 +7,19 @@ class Topic extends Model { use HasFactory; - - protected $fillable = ['title', 'body', 'user_id', 'category_id', 'reply_count', 'view_count', 'last_reply_user_id', 'order', 'excerpt', 'slug']; + + protected $fillable = [ + 'title', 'body', 'user_id', 'category_id', 'reply_count', + 'view_count', 'last_reply_user_id', 'order', 'excerpt', 'slug', + ]; + + public function category() + { + return $this->belongsTo(Category::class); + } + + public function user() + { + return $this->belongsTo(User::class); + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 330b6b265..39626036c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -26,6 +26,6 @@ public function boot() \App\Models\User::observe(\App\Observers\UserObserver::class); \App\Models\Topic::observe(\App\Observers\TopicObserver::class); - // + \Illuminate\Pagination\Paginator::useBootstrap(); } } diff --git a/public/css/app.css b/public/css/app.css index 910f890e4..8b0025beb 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -20512,3 +20512,36 @@ body { border-radius: 4px; padding: 3px; } + +/* Topic Index Page */ +.topics-index-page .topic-list .nav > li > a { + position: relative; + display: block; + padding: 5px 14px; + font-size: 0.9em; +} +.topics-index-page .topic-list a { + color: #444444; + text-decoration: none; +} +.topics-index-page .topic-list .meta { + font-size: 0.9em; + color: #b3b3b3; +} +.topics-index-page .topic-list .meta a { + color: #b3b3b3; +} +.topics-index-page .topic-list .badge { + background-color: #d8d8d8 !important; +} +.topics-index-page .topic-list hr { + margin-top: 12px; + margin-bottom: 12px; + border: 0; + border-top: 1px solid #979da0; +} + +/* Add container and footer space */ +#app > div.container { + margin-bottom: 100px; +} diff --git a/public/mix-manifest.json b/public/mix-manifest.json index aad2caf4c..588b531a6 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { "/js/app.js": "/js/app.js?id=36bfe725c8692a7363939a4c176b4bfd", - "/css/app.css": "/css/app.css?id=d1575ba29784e610931c0de7bf01e362" + "/css/app.css": "/css/app.css?id=df92c9da99f58166339e209103301635" } diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 9fc1690c3..8aa7baab8 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -72,3 +72,45 @@ body { padding: 3px; } } + +/* Topic Index Page */ +.topics-index-page { + .topic-list { + .nav>li>a { + position: relative; + display: block; + padding: 5px 14px; + font-size: 0.9em; + } + + a { + color: #444444; + text-decoration: none; + } + + .meta { + font-size: 0.9em; + color: #b3b3b3; + + a { + color: #b3b3b3; + } + } + + .badge { + background-color: #d8d8d8!important; + } + + hr { + margin-top: 12px; + margin-bottom: 12px; + border: 0; + border-top: 1px solid #979da0; + } + } +} + +/* Add container and footer space */ +#app > div.container { + margin-bottom: 100px; +} diff --git a/resources/views/topics/_sidebar.blade.php b/resources/views/topics/_sidebar.blade.php new file mode 100644 index 000000000..af5b08eb1 --- /dev/null +++ b/resources/views/topics/_sidebar.blade.php @@ -0,0 +1,5 @@ +
+
+ 右边导航栏 +
+
diff --git a/resources/views/topics/_topic_list.blade.php b/resources/views/topics/_topic_list.blade.php new file mode 100644 index 000000000..240011ea8 --- /dev/null +++ b/resources/views/topics/_topic_list.blade.php @@ -0,0 +1,51 @@ +@if (count($topics)) + + +@else +
暂无数据 ~_~
+@endif diff --git a/resources/views/topics/index.blade.php b/resources/views/topics/index.blade.php index cb9690632..ff49aac14 100644 --- a/resources/views/topics/index.blade.php +++ b/resources/views/topics/index.blade.php @@ -1,61 +1,34 @@ @extends('layouts.app') +@section('title', '话题列表') + @section('content') -
-
+ +
+
-
-

- Topic - Create -

+ +
- @if($topics->count()) - - - - - - - - - - - @foreach($topics as $topic) - - - - - - - - @endforeach - -
#Title Body User_id Category_id Reply_count View_count Last_reply_user_id Order Excerpt SlugOPTIONS
{{$topic->id}}{{$topic->title}} {{$topic->body}} {{$topic->user_id}} {{$topic->category_id}} {{$topic->reply_count}} {{$topic->view_count}} {{$topic->last_reply_user_id}} {{$topic->order}} {{$topic->excerpt}} {{$topic->slug}} - - V - - - - E - - -
- {{csrf_field()}} - - - -
-
- {!! $topics->render() !!} - @else -

Empty!

- @endif + {{-- 话题列表 --}} + @include('topics._topic_list', ['topics' => $topics]) + {{-- 分页 --}} +
+ {!! $topics->appends(Request::except('page'))->render() !!} +
+ +
@endsection