Skip to content

Commit ee1ca76

Browse files
committed
Administrators can reset trending threads.
1 parent 6b09747 commit ee1ca76

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use App\Thread;
6+
use App\Trending;
7+
use App\Http\Controllers\Controller;
8+
9+
class ThreadController extends Controller
10+
{
11+
public function index(Trending $trending)
12+
{
13+
return view('admin.threads.index', ['trending' => $trending->get()]);
14+
}
15+
16+
public function reset(Thread $thread, Trending $trending)
17+
{
18+
$trending->reset($thread);
19+
20+
return back()->with('flash', trans('messages.admin_reset_threads_trending_success'));
21+
}
22+
}

resources/lang/en/messages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,6 @@
121121
'admin_new_channel' => 'New channel',
122122
'admin_add_channel' => 'Add new channel',
123123
'admin_add_channel_success' => 'Channel created successfully!',
124+
'admin_reset_threads_trending' => 'Reset all trending threads',
125+
'admin_reset_threads_trending_success' => 'Reset all trending threads succeeded!',
124126
];

resources/lang/zh-CN/messages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,6 @@
121121
'admin_new_channel' => '新频道',
122122
'admin_add_channel' => '添加新频道',
123123
'admin_add_channel_success' => '频道创建成功!',
124+
'admin_reset_threads_trending' => '重置热门话题',
125+
'admin_reset_threads_trending_success' => '重置热门话题成功!',
124126
];

resources/views/admin/layouts/app.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<li class="nav-link" role="presentation">
1212
<a href="{{ route('admin.channel.index') }}">@lang('messages.nav_channels')</a>
1313
</li>
14+
<li class="nav-link" role="presentation">
15+
<a href="{{ route('admin.thread.index') }}">@lang('messages.threads_trending')</a>
16+
</li>
1417
</ul>
1518
</div>
1619

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@extends('admin.layouts.app')
2+
3+
@section('title')
4+
@lang('messages.admin_dashboard') / @lang('messages.threads_trending') - {{ config('app.name') }}
5+
@endsection
6+
7+
@section('administration-content')
8+
<p>
9+
<a class="btn btn-sm btn-dark" href="{{ route('admin.thread.reset') }}">
10+
@lang('messages.admin_reset_threads_trending') <span class="glyphicon glyphicon-plus"></span>
11+
</a>
12+
</p>
13+
14+
<div class="card">
15+
@forelse ($trending as $thread)
16+
<li class="list-group-item">
17+
<a href="{{ url($thread->path) }}" style="color: #333333;">
18+
{{ $thread->title }}
19+
</a>
20+
</li>
21+
@empty
22+
@lang('messages.threads_no_trending')
23+
@endforelse
24+
</div>
25+
@endsection

routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,6 @@
7272
Route::post('/channel', 'ChannelController@store')->name('admin.channel.store');
7373
Route::get('/channel', 'ChannelController@index')->name('admin.channel.index');
7474
Route::get('/channel/create', 'ChannelController@create')->name('admin.channel.create');
75+
Route::get('/thread', 'ThreadController@index')->name('admin.thread.index');
76+
Route::get('/thread/reset', 'ThreadController@reset')->name('admin.thread.reset');
7577
});

0 commit comments

Comments
 (0)