This commit is contained in:
fthvgb1 2018-01-15 23:24:11 +08:00
parent f855bdbb2b
commit 46304b7935
23 changed files with 403 additions and 16 deletions

View File

@ -33,7 +33,8 @@ class TopicsController extends Controller
if (!empty($topic->slug) && $topic->slug != $request->slug) { if (!empty($topic->slug) && $topic->slug != $request->slug) {
return redirect($topic->link(), 301); return redirect($topic->link(), 301);
} }
return view('topics.show', compact('topic')); $replies = $topic->replies;
return view('topics.show', compact('topic', 'replies'));
} }
public function store(TopicRequest $request, Topic $topic) public function store(TopicRequest $request, Topic $topic)

19
app/Models/Reply.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
class Reply extends Model
{
protected $fillable = ['content'];
public function topic()
{
return $this->belongsTo(Topic::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}

View File

@ -41,6 +41,12 @@ class Topic extends Model
return $query->orderBy('created_at', 'desc'); return $query->orderBy('created_at', 'desc');
} }
public function replies()
{
return $this->hasMany(Reply::class);
}
public function user() public function user()
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);

View File

@ -37,6 +37,11 @@ class User extends Authenticatable
return $this->id == $model->user_id; return $this->id == $model->user_id;
} }
public function replies()
{
return $this->hasMany(Reply::class, 'user_id');
}
public function topics() public function topics()
{ {
return $this->hasMany(Topic::class); return $this->hasMany(Topic::class);

View File

@ -0,0 +1,21 @@
<?php
namespace App\Observers;
use App\Models\Reply;
// creating, created, updating, updated, saving,
// saved, deleting, deleted, restoring, restored
class ReplyObserver
{
public function creating(Reply $reply)
{
//
}
public function updating(Reply $reply)
{
//
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Policies;
use App\Models\Reply;
use App\Models\User;
class ReplyPolicy extends Policy
{
public function update(User $user, Reply $reply)
{
// return $reply->user_id == $user->id;
return true;
}
public function destroy(User $user, Reply $reply)
{
return true;
}
}

View File

@ -14,6 +14,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $policies = [ protected $policies = [
\App\Models\Reply::class => \App\Policies\ReplyPolicy::class,
\App\Models\Topic::class => \App\Policies\TopicPolicy::class, \App\Models\Topic::class => \App\Policies\TopicPolicy::class,
'App\Model' => 'App\Policies\ModelPolicy', 'App\Model' => 'App\Policies\ModelPolicy',
User::class => UserPolicy::class, User::class => UserPolicy::class,

View File

@ -0,0 +1,13 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Reply::class, function (Faker $faker) {
$time = $faker->dateTimeThisMonth();
return [
'content' => $faker->sentence(),
'created_at' => $time,
'updated_at' => $time,
];
});

View File

@ -9,7 +9,7 @@ class CreateTopicsTable extends Migration
{ {
Schema::create('topics', function (Blueprint $table) { Schema::create('topics', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('"title')->index(); $table->string('title')->index();
$table->text('body'); $table->text('body');
$table->integer('user_id')->unsigned()->index(); $table->integer('user_id')->unsigned()->index();
$table->integer('category_id')->unsigned()->index(); $table->integer('category_id')->unsigned()->index();

View File

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateRepliesTable extends Migration
{
public function up()
{
Schema::create('replies', function (Blueprint $table) {
$table->increments('id');
$table->integer('topic_id')->unsigned()->default(0)->index();
$table->integer('user_id')->unsigned()->default(0)->index();
$table->text('content');
$table->timestamps();
});
}
public function down()
{
Schema::drop('replies');
}
}

View File

@ -13,5 +13,6 @@ class DatabaseSeeder extends Seeder
{ {
$this->call(UsersTableSeeder::class); $this->call(UsersTableSeeder::class);
$this->call(TopicsTableSeeder::class); $this->call(TopicsTableSeeder::class);
$this->call(ReplysTableSeeder::class);
} }
} }

View File

@ -0,0 +1,36 @@
<?php
use App\Models\Reply;
use Illuminate\Database\Seeder;
class ReplysTableSeeder extends Seeder
{
public function run()
{
// 所有用户 ID 数组,如:[1,2,3,4]
$user_ids = \App\Models\User::all()->pluck('id')->toArray();
// 所有话题 ID 数组,如:[1,2,3,4]
$topic_ids = \App\Models\Topic::all()->pluck('id')->toArray();
// 获取 Faker 实例
$faker = app(Faker\Generator::class);
$replys = factory(Reply::class)
->times(1000)
->make()
->each(function ($reply, $index)
use ($user_ids, $topic_ids, $faker) {
// 从用户 ID 数组中随机取出一个并赋值
$reply->user_id = $faker->randomElement($user_ids);
// 话题 ID同上
$reply->topic_id = $faker->randomElement($topic_ids);
});
// 将数据集合转换为数组,并插入到数据库中
Reply::insert($replys->toArray());
}
}

View File

@ -27,7 +27,6 @@ class TopicsTableSeeder extends Seeder
// 话题分类,同上 // 话题分类,同上
$topic->category_id = $faker->randomElement($category_ids); $topic->category_id = $faker->randomElement($category_ids);
}); });
// 将数据集合转换为数组,并插入到数据库中 // 将数据集合转换为数组,并插入到数据库中
Topic::insert($topics->toArray()); Topic::insert($topics->toArray());
} }

View File

@ -39,7 +39,7 @@ class UsersTableSeeder extends Seeder
$user = \App\Models\User::find(1); $user = \App\Models\User::find(1);
$user->name = 'fthvgb1'; $user->name = 'fthvgb1';
$user->email = 'fthvgb1@163.com'; $user->email = 'fthvgb1@163.com';
$user->avatar = ''; $user->password = bcrypt('123456');
$user->save(); $user->save();
} }

29
public/css/app.css vendored
View File

@ -8442,16 +8442,21 @@ body {
margin: 12px 0; margin: 12px 0;
} }
.users-show-page .meta {
font-size: .9em;
color: #b3b3b3;
}
.users-show-page .reply-content {
margin: 6px 0;
}
.users-show-page .list-group .list-group-item { .users-show-page .list-group .list-group-item {
border: none; border: none;
margin-bottom: 0px; margin-bottom: 0px;
border-bottom: 1px solid #efefef; border-bottom: 1px solid #efefef;
} }
.users-show-page .list-group .list-group-item .meta {
color: #b3b3b3;
}
/* Topic Index Page */ /* Topic Index Page */
.topics-index-page .topic-list .nav > li > a, .topics-index-page .topic-list .nav > li > a,
@ -8956,3 +8961,19 @@ body {
line-height: 38px; line-height: 38px;
} }
.topic-reply hr {
margin-top: 16px;
margin-bottom: 16px;
}
.topic-reply a {
color: inherit;
}
.topic-reply .meta {
font-size: .9em;
color: #b3b3b3;
}
/* Topic Index Page */

View File

@ -4,6 +4,7 @@
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }
.simditor-icon { .simditor-icon {
display: inline-block; display: inline-block;
font: normal normal normal 14px/1 'Simditor'; font: normal normal normal 14px/1 'Simditor';
@ -142,10 +143,12 @@
position: relative; position: relative;
border: 1px solid #c9d8db; border: 1px solid #c9d8db;
} }
.simditor .simditor-wrapper { .simditor .simditor-wrapper {
position: relative; position: relative;
background: #ffffff; background: #ffffff;
} }
.simditor .simditor-wrapper > textarea { .simditor .simditor-wrapper > textarea {
display: none !important; display: none !important;
width: 100%; width: 100%;
@ -160,6 +163,7 @@
background: transparent; background: transparent;
resize: none; resize: none;
} }
.simditor .simditor-wrapper .simditor-placeholder { .simditor .simditor-wrapper .simditor-placeholder {
display: none; display: none;
position: absolute; position: absolute;
@ -172,12 +176,14 @@
color: #999999; color: #999999;
background: transparent; background: transparent;
} }
.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar { .simditor .simditor-wrapper.toolbar-floating .simditor-toolbar {
position: fixed; position: fixed;
top: 0; top: 0;
z-index: 10; z-index: 10;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.1); box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
} }
.simditor .simditor-wrapper .simditor-image-loading { .simditor .simditor-wrapper .simditor-image-loading {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -186,6 +192,7 @@
left: 0; left: 0;
z-index: 2; z-index: 2;
} }
.simditor .simditor-wrapper .simditor-image-loading .progress { .simditor .simditor-wrapper .simditor-image-loading .progress {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -194,6 +201,7 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
} }
.simditor .simditor-body { .simditor .simditor-body {
padding: 22px 15px 40px; padding: 22px 15px 40px;
min-height: 300px; min-height: 300px;
@ -203,18 +211,23 @@
z-index: 1; z-index: 1;
background: transparent; background: transparent;
} }
.simditor .simditor-body a.selected { .simditor .simditor-body a.selected {
background: #b3d4fd; background: #b3d4fd;
} }
.simditor .simditor-body a.simditor-mention { .simditor .simditor-body a.simditor-mention {
cursor: pointer; cursor: pointer;
} }
.simditor .simditor-body .simditor-table { .simditor .simditor-body .simditor-table {
position: relative; position: relative;
} }
.simditor .simditor-body .simditor-table.resizing { .simditor .simditor-body .simditor-table.resizing {
cursor: col-resize; cursor: col-resize;
} }
.simditor .simditor-body .simditor-table .simditor-resize-handle { .simditor .simditor-body .simditor-table .simditor-resize-handle {
position: absolute; position: absolute;
left: 0; left: 0;
@ -223,6 +236,7 @@
height: 100%; height: 100%;
cursor: col-resize; cursor: col-resize;
} }
.simditor .simditor-body pre { .simditor .simditor-body pre {
/*min-height: 28px;*/ /*min-height: 28px;*/
box-sizing: border-box; box-sizing: border-box;
@ -230,12 +244,15 @@
word-wrap: break-word !important; word-wrap: break-word !important;
white-space: pre-wrap !important; white-space: pre-wrap !important;
} }
.simditor .simditor-body img { .simditor .simditor-body img {
cursor: pointer; cursor: pointer;
} }
.simditor .simditor-body img.selected { .simditor .simditor-body img.selected {
box-shadow: 0 0 0 4px #cccccc; box-shadow: 0 0 0 4px #cccccc;
} }
.simditor .simditor-paste-bin { .simditor .simditor-paste-bin {
position: fixed; position: fixed;
bottom: 10px; bottom: 10px;
@ -250,21 +267,25 @@
opacity: 0; opacity: 0;
-webkit-user-select: text; -webkit-user-select: text;
} }
.simditor .simditor-toolbar { .simditor .simditor-toolbar {
border-bottom: 1px solid #eeeeee; border-bottom: 1px solid #eeeeee;
background: #ffffff; background: #ffffff;
width: 100%; width: 100%;
} }
.simditor .simditor-toolbar > ul { .simditor .simditor-toolbar > ul {
margin: 0; margin: 0;
padding: 0 0 0 6px; padding: 0 0 0 6px;
list-style: none; list-style: none;
} }
.simditor .simditor-toolbar > ul > li { .simditor .simditor-toolbar > ul > li {
position: relative; position: relative;
display: inline-block; display: inline-block;
font-size: 0; font-size: 0;
} }
.simditor .simditor-toolbar > ul > li > span.separator { .simditor .simditor-toolbar > ul > li > span.separator {
display: inline-block; display: inline-block;
background: #cfcfcf; background: #cfcfcf;
@ -273,6 +294,7 @@
margin: 11px 15px; margin: 11px 15px;
vertical-align: middle; vertical-align: middle;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item { .simditor .simditor-toolbar > ul > li > .toolbar-item {
display: inline-block; display: inline-block;
width: 46px; width: 46px;
@ -285,50 +307,63 @@
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item span { .simditor .simditor-toolbar > ul > li > .toolbar-item span {
opacity: 0.6; opacity: 0.6;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item span.simditor-icon { .simditor .simditor-toolbar > ul > li > .toolbar-item span.simditor-icon {
display: inline; display: inline;
line-height: normal; line-height: normal;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item:hover span { .simditor .simditor-toolbar > ul > li > .toolbar-item:hover span {
opacity: 1; opacity: 1;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.active { .simditor .simditor-toolbar > ul > li > .toolbar-item.active {
background: #eeeeee; background: #eeeeee;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.active span { .simditor .simditor-toolbar > ul > li > .toolbar-item.active span {
opacity: 1; opacity: 1;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled { .simditor .simditor-toolbar > ul > li > .toolbar-item.disabled {
cursor: default; cursor: default;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled span { .simditor .simditor-toolbar > ul > li > .toolbar-item.disabled span {
opacity: 0.3; opacity: 0.3;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title span:before { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title span:before {
content: "H"; content: "H";
font-size: 19px; font-size: 19px;
font-weight: bold; font-weight: bold;
font-family: 'Times New Roman'; font-family: 'Times New Roman';
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h1 span:before { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h1 span:before {
content: 'H1'; content: 'H1';
font-size: 18px; font-size: 18px;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h2 span:before { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h2 span:before {
content: 'H2'; content: 'H2';
font-size: 18px; font-size: 18px;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h3 span:before { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h3 span:before {
content: 'H3'; content: 'H3';
font-size: 18px; font-size: 18px;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image > input[type=file] { .simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image > input[type=file] {
position: absolute; position: absolute;
right: 0px; right: 0px;
@ -337,18 +372,22 @@
font-size: 100px; font-size: 100px;
cursor: pointer; cursor: pointer;
} }
.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item { .simditor .simditor-toolbar > ul > li.menu-on .toolbar-item {
position: relative; position: relative;
z-index: 20; z-index: 20;
background: #ffffff; background: #ffffff;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
} }
.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item span { .simditor .simditor-toolbar > ul > li.menu-on .toolbar-item span {
opacity: 1; opacity: 1;
} }
.simditor .simditor-toolbar > ul > li.menu-on .toolbar-menu { .simditor .simditor-toolbar > ul > li.menu-on .toolbar-menu {
display: block; display: block;
} }
.simditor .simditor-toolbar .toolbar-menu { .simditor .simditor-toolbar .toolbar-menu {
display: none; display: none;
position: absolute; position: absolute;
@ -359,6 +398,7 @@
text-align: left; text-align: left;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
} }
.simditor .simditor-toolbar .toolbar-menu:before { .simditor .simditor-toolbar .toolbar-menu:before {
content: ''; content: '';
display: block; display: block;
@ -369,12 +409,14 @@
top: -3px; top: -3px;
left: 0; left: 0;
} }
.simditor .simditor-toolbar .toolbar-menu ul { .simditor .simditor-toolbar .toolbar-menu ul {
min-width: 160px; min-width: 160px;
list-style: none; list-style: none;
margin: 0; margin: 0;
padding: 10px 1px; padding: 10px 1px;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item {
display: block; display: block;
font-size: 16px; font-size: 16px;
@ -383,29 +425,36 @@
text-decoration: none; text-decoration: none;
color: #666666; color: #666666;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item:hover { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item:hover {
background: #f6f6f6; background: #f6f6f6;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h1 { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h1 {
font-size: 24px; font-size: 24px;
color: #333333; color: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h2 { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h2 {
font-size: 22px; font-size: 22px;
color: #333333; color: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h3 { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h3 {
font-size: 20px; font-size: 20px;
color: #333333; color: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h4 { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h4 {
font-size: 18px; font-size: 18px;
color: #333333; color: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h5 { .simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h5 {
font-size: 16px; font-size: 16px;
color: #333333; color: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu ul > li .separator { .simditor .simditor-toolbar .toolbar-menu ul > li .separator {
display: block; display: block;
border-top: 1px solid #cccccc; border-top: 1px solid #cccccc;
@ -414,19 +463,23 @@
font-size: 0; font-size: 0;
margin: 6px 0; margin: 6px 0;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color {
width: 96px; width: 96px;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list {
height: 40px; height: 40px;
margin: 10px 6px 6px 10px; margin: 10px 6px 6px 10px;
padding: 0; padding: 0;
min-width: 0; min-width: 0;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li {
float: left; float: left;
margin: 0 4px 4px 0; margin: 0 4px 4px 0;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color {
display: block; display: block;
width: 16px; width: 16px;
@ -434,47 +487,60 @@
background: #dfdfdf; background: #dfdfdf;
border-radius: 2px; border-radius: 2px;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover {
opacity: 0.8; opacity: 0.8;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default {
background: #333333; background: #333333;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1 {
background: #E33737; background: #E33737;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2 {
background: #e28b41; background: #e28b41;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3 {
background: #c8a732; background: #c8a732;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4 {
background: #209361; background: #209361;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5 {
background: #418caf; background: #418caf;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6 {
background: #aa8773; background: #aa8773;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7 { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7 {
background: #999999; background: #999999;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table {
background: #ffffff; background: #ffffff;
padding: 1px; padding: 1px;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table {
border: none; border: none;
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
table-layout: fixed; table-layout: fixed;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td {
padding: 0; padding: 0;
cursor: pointer; cursor: pointer;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before {
width: 16px; width: 16px;
height: 16px; height: 16px;
@ -483,19 +549,24 @@
display: block; display: block;
content: ""; content: "";
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before {
background: #cfcfcf; background: #cfcfcf;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table {
display: none; display: none;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li {
white-space: nowrap; white-space: nowrap;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file] { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file] {
position: absolute; position: absolute;
right: 0px; right: 0px;
@ -504,15 +575,19 @@
font-size: 100px; font-size: 100px;
cursor: pointer; cursor: pointer;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment {
width: 100%; width: 100%;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul {
min-width: 100%; min-width: 100%;
} }
.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item { .simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item {
text-align: center; text-align: center;
} }
.simditor .simditor-popover { .simditor .simditor-popover {
display: none; display: none;
padding: 5px 8px 0; padding: 5px 8px 0;
@ -522,31 +597,37 @@
position: absolute; position: absolute;
z-index: 2; z-index: 2;
} }
.simditor .simditor-popover .settings-field { .simditor .simditor-popover .settings-field {
margin: 0 0 5px 0; margin: 0 0 5px 0;
font-size: 12px; font-size: 12px;
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
} }
.simditor .simditor-popover .settings-field label { .simditor .simditor-popover .settings-field label {
display: inline-block; display: inline-block;
margin: 0 5px 0 0; margin: 0 5px 0 0;
} }
.simditor .simditor-popover .settings-field input[type=text] { .simditor .simditor-popover .settings-field input[type=text] {
display: inline-block; display: inline-block;
width: 200px; width: 200px;
box-sizing: border-box; box-sizing: border-box;
font-size: 12px; font-size: 12px;
} }
.simditor .simditor-popover .settings-field input[type=text].image-size { .simditor .simditor-popover .settings-field input[type=text].image-size {
width: 83px; width: 83px;
} }
.simditor .simditor-popover .settings-field .times { .simditor .simditor-popover .settings-field .times {
display: inline-block; display: inline-block;
width: 26px; width: 26px;
font-size: 12px; font-size: 12px;
text-align: center; text-align: center;
} }
.simditor .simditor-popover.link-popover .btn-unlink, .simditor .simditor-popover.image-popover .btn-upload, .simditor .simditor-popover.image-popover .btn-restore { .simditor .simditor-popover.link-popover .btn-unlink, .simditor .simditor-popover.image-popover .btn-upload, .simditor .simditor-popover.image-popover .btn-restore {
display: inline-block; display: inline-block;
margin: 0 0 0 5px; margin: 0 0 0 5px;
@ -554,18 +635,22 @@
font-size: 14px; font-size: 14px;
outline: 0; outline: 0;
} }
.simditor .simditor-popover.link-popover .btn-unlink span, .simditor .simditor-popover.image-popover .btn-upload span, .simditor .simditor-popover.image-popover .btn-restore span { .simditor .simditor-popover.link-popover .btn-unlink span, .simditor .simditor-popover.image-popover .btn-upload span, .simditor .simditor-popover.image-popover .btn-restore span {
opacity: 0.6; opacity: 0.6;
} }
.simditor .simditor-popover.link-popover .btn-unlink:hover span, .simditor .simditor-popover.image-popover .btn-upload:hover span, .simditor .simditor-popover.image-popover .btn-restore:hover span { .simditor .simditor-popover.link-popover .btn-unlink:hover span, .simditor .simditor-popover.image-popover .btn-upload:hover span, .simditor .simditor-popover.image-popover .btn-restore:hover span {
opacity: 1; opacity: 1;
} }
.simditor .simditor-popover.image-popover .btn-upload { .simditor .simditor-popover.image-popover .btn-upload {
position: relative; position: relative;
display: inline-block; display: inline-block;
overflow: hidden; overflow: hidden;
vertical-align: middle; vertical-align: middle;
} }
.simditor .simditor-popover.image-popover .btn-upload input[type=file] { .simditor .simditor-popover.image-popover .btn-upload input[type=file] {
position: absolute; position: absolute;
right: 0px; right: 0px;
@ -574,6 +659,7 @@
height: 100%; height: 100%;
width: 28px; width: 28px;
} }
.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar { .simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar {
position: absolute; position: absolute;
top: 0; top: 0;
@ -589,96 +675,123 @@
outline: none; outline: none;
word-wrap: break-word; word-wrap: break-word;
} }
.simditor .simditor-body > :first-child, .editor-style > :first-child { .simditor .simditor-body > :first-child, .editor-style > :first-child {
margin-top: 0 !important; margin-top: 0 !important;
} }
.simditor .simditor-body a, .editor-style a { .simditor .simditor-body a, .editor-style a {
color: #4298BA; color: #4298BA;
text-decoration: none; text-decoration: none;
word-break: break-all; word-break: break-all;
} }
.simditor .simditor-body a:visited, .editor-style a:visited { .simditor .simditor-body a:visited, .editor-style a:visited {
color: #4298BA; color: #4298BA;
} }
.simditor .simditor-body a:hover, .editor-style a:hover { .simditor .simditor-body a:hover, .editor-style a:hover {
color: #0F769F; color: #0F769F;
} }
.simditor .simditor-body a:active, .editor-style a:active { .simditor .simditor-body a:active, .editor-style a:active {
color: #9E792E; color: #9E792E;
} }
.simditor .simditor-body a:hover, .simditor .simditor-body a:active, .editor-style a:hover, .editor-style a:active { .simditor .simditor-body a:hover, .simditor .simditor-body a:active, .editor-style a:hover, .editor-style a:active {
outline: 0; outline: 0;
} }
.simditor .simditor-body h1, .simditor .simditor-body h2, .simditor .simditor-body h3, .simditor .simditor-body h4, .simditor .simditor-body h5, .simditor .simditor-body h6, .editor-style h1, .editor-style h2, .editor-style h3, .editor-style h4, .editor-style h5, .editor-style h6 { .simditor .simditor-body h1, .simditor .simditor-body h2, .simditor .simditor-body h3, .simditor .simditor-body h4, .simditor .simditor-body h5, .simditor .simditor-body h6, .editor-style h1, .editor-style h2, .editor-style h3, .editor-style h4, .editor-style h5, .editor-style h6 {
font-weight: normal; font-weight: normal;
margin: 40px 0 20px; margin: 40px 0 20px;
color: #000000; color: #000000;
} }
.simditor .simditor-body h1, .editor-style h1 { .simditor .simditor-body h1, .editor-style h1 {
font-size: 24px; font-size: 24px;
} }
.simditor .simditor-body h2, .editor-style h2 { .simditor .simditor-body h2, .editor-style h2 {
font-size: 22px; font-size: 22px;
} }
.simditor .simditor-body h3, .editor-style h3 { .simditor .simditor-body h3, .editor-style h3 {
font-size: 20px; font-size: 20px;
} }
.simditor .simditor-body h4, .editor-style h4 { .simditor .simditor-body h4, .editor-style h4 {
font-size: 18px; font-size: 18px;
} }
.simditor .simditor-body h5, .editor-style h5 { .simditor .simditor-body h5, .editor-style h5 {
font-size: 16px; font-size: 16px;
} }
.simditor .simditor-body h6, .editor-style h6 { .simditor .simditor-body h6, .editor-style h6 {
font-size: 16px; font-size: 16px;
} }
.simditor .simditor-body p, .simditor .simditor-body div, .editor-style p, .editor-style div { .simditor .simditor-body p, .simditor .simditor-body div, .editor-style p, .editor-style div {
word-wrap: break-word; word-wrap: break-word;
margin: 0 0 15px 0; margin: 0 0 15px 0;
color: #333; color: #333;
word-wrap: break-word; word-wrap: break-word;
} }
.simditor .simditor-body b, .simditor .simditor-body strong, .editor-style b, .editor-style strong { .simditor .simditor-body b, .simditor .simditor-body strong, .editor-style b, .editor-style strong {
font-weight: bold; font-weight: bold;
} }
.simditor .simditor-body i, .simditor .simditor-body em, .editor-style i, .editor-style em { .simditor .simditor-body i, .simditor .simditor-body em, .editor-style i, .editor-style em {
font-style: italic; font-style: italic;
} }
.simditor .simditor-body u, .editor-style u { .simditor .simditor-body u, .editor-style u {
text-decoration: underline; text-decoration: underline;
} }
.simditor .simditor-body strike, .simditor .simditor-body del, .editor-style strike, .editor-style del { .simditor .simditor-body strike, .simditor .simditor-body del, .editor-style strike, .editor-style del {
text-decoration: line-through; text-decoration: line-through;
} }
.simditor .simditor-body ul, .simditor .simditor-body ol, .editor-style ul, .editor-style ol { .simditor .simditor-body ul, .simditor .simditor-body ol, .editor-style ul, .editor-style ol {
list-style: disc outside none; list-style: disc outside none;
margin: 15px 0; margin: 15px 0;
padding: 0 0 0 40px; padding: 0 0 0 40px;
line-height: 1.6; line-height: 1.6;
} }
.simditor .simditor-body ul li, .simditor .simditor-body ol li, .editor-style ul li, .editor-style ol li { .simditor .simditor-body ul li, .simditor .simditor-body ol li, .editor-style ul li, .editor-style ol li {
list-style-type: inherit; list-style-type: inherit;
} }
.simditor .simditor-body ul ul, .simditor .simditor-body ul ol, .simditor .simditor-body ol ul, .simditor .simditor-body ol ol, .editor-style ul ul, .editor-style ul ol, .editor-style ol ul, .editor-style ol ol { .simditor .simditor-body ul ul, .simditor .simditor-body ul ol, .simditor .simditor-body ol ul, .simditor .simditor-body ol ol, .editor-style ul ul, .editor-style ul ol, .editor-style ol ul, .editor-style ol ol {
padding-left: 30px; padding-left: 30px;
} }
.simditor .simditor-body ul ul, .simditor .simditor-body ol ul, .editor-style ul ul, .editor-style ol ul { .simditor .simditor-body ul ul, .simditor .simditor-body ol ul, .editor-style ul ul, .editor-style ol ul {
list-style: circle outside none; list-style: circle outside none;
} }
.simditor .simditor-body ul ul ul, .simditor .simditor-body ol ul ul, .editor-style ul ul ul, .editor-style ol ul ul { .simditor .simditor-body ul ul ul, .simditor .simditor-body ol ul ul, .editor-style ul ul ul, .editor-style ol ul ul {
list-style: square outside none; list-style: square outside none;
} }
.simditor .simditor-body ol, .editor-style ol { .simditor .simditor-body ol, .editor-style ol {
list-style: decimal; list-style: decimal;
} }
.simditor .simditor-body blockquote, .editor-style blockquote { .simditor .simditor-body blockquote, .editor-style blockquote {
border-left: 6px solid #ddd; border-left: 6px solid #ddd;
padding: 5px 0 5px 10px; padding: 5px 0 5px 10px;
margin: 15px 0 15px 15px; margin: 15px 0 15px 15px;
} }
.simditor .simditor-body blockquote > :first-child, .editor-style blockquote > :first-child { .simditor .simditor-body blockquote > :first-child, .editor-style blockquote > :first-child {
margin-top: 0; margin-top: 0;
} }
.simditor .simditor-body code, .editor-style code { .simditor .simditor-body code, .editor-style code {
display: inline-block; display: inline-block;
padding: 0 4px; padding: 0 4px;
@ -688,6 +801,7 @@
font-size: 13px; font-size: 13px;
font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace; font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
} }
.simditor .simditor-body pre, .editor-style pre { .simditor .simditor-body pre, .editor-style pre {
padding: 10px 5px 10px 10px; padding: 10px 5px 10px 10px;
margin: 15px 0; margin: 15px 0;
@ -701,6 +815,7 @@
word-wrap: normal; word-wrap: normal;
overflow-x: auto; overflow-x: auto;
} }
.simditor .simditor-body pre code, .editor-style pre code { .simditor .simditor-body pre code, .editor-style pre code {
display: block; display: block;
padding: 0; padding: 0;
@ -708,6 +823,7 @@
background: none; background: none;
border-radius: 0; border-radius: 0;
} }
.simditor .simditor-body hr, .editor-style hr { .simditor .simditor-body hr, .editor-style hr {
display: block; display: block;
height: 0px; height: 0px;
@ -716,6 +832,7 @@
margin: 15px 0; margin: 15px 0;
padding: 0; padding: 0;
} }
.simditor .simditor-body table, .editor-style table { .simditor .simditor-body table, .editor-style table {
width: 100%; width: 100%;
table-layout: fixed; table-layout: fixed;
@ -723,9 +840,11 @@
border-spacing: 0; border-spacing: 0;
margin: 15px 0; margin: 15px 0;
} }
.simditor .simditor-body table thead, .editor-style table thead { .simditor .simditor-body table thead, .editor-style table thead {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.simditor .simditor-body table td, .simditor .simditor-body table th, .editor-style table td, .editor-style table th { .simditor .simditor-body table td, .simditor .simditor-body table th, .editor-style table td, .editor-style table th {
min-width: 40px; min-width: 40px;
height: 30px; height: 30px;
@ -735,9 +854,11 @@
text-align: left; text-align: left;
box-sizing: border-box; box-sizing: border-box;
} }
.simditor .simditor-body table td.active, .simditor .simditor-body table th.active, .editor-style table td.active, .editor-style table th.active { .simditor .simditor-body table td.active, .simditor .simditor-body table th.active, .editor-style table td.active, .editor-style table th.active {
background-color: #ffffee; background-color: #ffffee;
} }
.simditor .simditor-body img, .editor-style img { .simditor .simditor-body img, .editor-style img {
margin: 0 5px; margin: 0 5px;
vertical-align: middle; vertical-align: middle;

View File

@ -94,16 +94,19 @@ body {
.pagination { .pagination {
margin: 12px 0; margin: 12px 0;
} }
.meta {
font-size: .9em;
color: #b3b3b3;
}
.reply-content {
margin: 6px 0;
}
.list-group { .list-group {
.list-group-item { .list-group-item {
border: none; border: none;
margin-bottom: 0px; margin-bottom: 0px;
border-bottom: 1px solid #efefef; border-bottom: 1px solid #efefef;
.meta {
color: #b3b3b3;
}
} }
} }
@ -154,3 +157,21 @@ body {
} }
} }
} }
.topic-reply {
hr {
margin-top: 16px;
margin-bottom: 16px;
}
a {
color: inherit;
}
.meta {
font-size: .9em;
color: #b3b3b3;
}
}
/* Topic Index Page */

View File

@ -0,0 +1,33 @@
<div class="reply-list">
@foreach ($replies as $index => $reply)
<div class=" media" name="reply{{ $reply->id }}" id="reply{{ $reply->id }}">
<div class="avatar pull-left">
<a href="{{ route('users.show', [$reply->user_id]) }}">
<img class="media-object img-thumbnail" alt="{{ $reply->user->name }}"
src="{{ $reply->user->avatar }}" style="width:48px;height:48px;"/>
</a>
</div>
<div class="infos">
<div class="media-heading">
<a href="{{ route('users.show', [$reply->user_id]) }}" title="{{ $reply->user->name }}">
{{ $reply->user->name }}
</a>
<span> </span>
<span class="meta" title="{{ $reply->created_at }}">{{ $reply->created_at->diffForHumans() }}</span>
{{-- 回复删除按钮 --}}
<span class="meta pull-right">
<a title="删除回复">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</a>
</span>
</div>
<div class="reply-content">
{!! $reply->content !!}
</div>
</div>
</div>
<hr>
@endforeach
</div>

View File

@ -63,6 +63,14 @@
</div> </div>
</div> </div>
{{-- 用户回复列表 --}}
<div class="panel panel-default topic-reply">
<div class="panel-body">
@include('topics._reply_box', ['topic' => $topic])
@include('topics._reply_list', ['replies' => $topic->replies()->with('user')->get()])
</div>
</div>
</div> </div>
</div> </div>
@endsection @endsection

View File

@ -0,0 +1,27 @@
@if (count($replies))
<ul class="list-group">
@foreach ($replies as $reply)
<li class="list-group-item">
<a href="{{ $reply->topic->link(['#reply' . $reply->id]) }}">
{{ $reply->topic->title }}
</a>
<div class="reply-content" style="margin: 6px 0;">
{!! $reply->content !!}
</div>
<div class="meta">
<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
回复于 {{ $reply->created_at->diffForHumans() }}
</div>
</li>
@endforeach
</ul>
@else
<div class="empty-block">暂无数据 ~_~</div>
@endif
{{-- 分页 --}}
{!! $replies->appends(Request::except('page'))->render() !!}

View File

@ -39,10 +39,19 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#">Ta 的话题</a></li> <li class="{{ active_class(if_query('tab', null)) }}">
<li><a href="#">Ta 的回复</a></li> <a href="{{ route('users.show', $user->id) }}">Ta 的话题</a>
</li>
<li class="{{ active_class(if_query('tab', 'replies')) }}">
<a href="{{ route('users.show', [$user->id, 'tab' => 'replies']) }}">Ta 的回复</a>
</li>
</ul> </ul>
@if(if_query('tab','replies'))
@include('users._replies', ['replies' => $user->replies()->recent()->paginate(5)])
@else
@include('users._topics', ['topics' => $user->topics()->recent()->paginate(5)]) @include('users._topics', ['topics' => $user->topics()->recent()->paginate(5)])
@endif
</div> </div>
</div> </div>

View File

@ -37,3 +37,5 @@ Route::get('topics/{topic}/{slug?}', 'TopicsController@show')->name('topics.show
Route::resource('categories', 'CategoriesController', ['only' => ['show']]); Route::resource('categories', 'CategoriesController', ['only' => ['show']]);
Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image'); Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image');
Route::resource('replies', 'RepliesController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]);