10000 Implement pinned threads · laravelio/laravel.io@c566bbc · GitHub
[go: up one dir, main page]

Skip to content

Commit c566bbc

Browse files
committed
Implement pinned threads
1 parent 2dfecdf commit c566bbc

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

app/Lio/Forum/Threads/ThreadRepository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function getByTagsPaginated(Collection $tags, $perPage = 20)
2020
}
2121

2222
$query->groupBy('forum_threads.id')
23+
->orderBy('pinned', 'desc')
2324
->orderBy('updated_at', 'desc');
2425

2526
return $query->paginate($perPage, ['forum_threads.*']);
@@ -44,6 +45,7 @@ public function getByTagsAndStatusPaginated(Collection $tags, $status, $perPage
4445
}
4546
}
4647

48+
$query->orderBy('pinned', 'desc');
4749
$query->orderBy('updated_at', 'desc');
4850

4951
return $query->paginate($perPage, ['forum_threads.*']);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class PinnedThreads extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('forum_threads', function (Blueprint $table) {
16+
$table->boolean('pinned');
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
Schema::table('forum_threads', function (Blueprint $table) {
28+
$table->dropColumn('pinned');
29+
});
30+
}
31+
}

app/views/forum/_thread_summary.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<div class="thread-summary">
22
{{ $thread->author->thumbnail }}
33
<div class="info">
4-
<h3><a href="{{ $thread->url }}">{{ $thread->subject }}</a></h3>
4+
<h3>
5+
<a href="{{ $thread->url }}">
6+
@if ($thread->pinned)
7+
[Pinned]
8+
@endif
9+
10+
{{ $thread->subject }}
11+
</a>
12+
</h3>
513
<ul class="meta">
614
<li>posted by <a href="{{ $thread->author->profileUrl }}">{{ $thread->author->name }}</a></li>
715
<li>updated {{ $thread->updated_ago }}</li>

app/views/forum/threads/_index_summary.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
{{ $thread->author->thumbnail }}
33

44
<div class="info">
5-
<h3><a href="{{ $thread->url }}">{{{ $thread->subject }}}</a></h3>
5+
<h3>
6+
<a href="{{ $thread->url }}">
7+
@if ($thread->pinned)
8+
[Pinned]
9+
@endif
10+
11+
{{{ $thread->subject }}}
12+
</a>
13+
</h3>
614

715
<div class="post-info">
816
@if ($thread->isSolved())

app/views/forum/threads/_thread.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<div class="thread {{ $thread->isQuestion() ? 'question' : '' }} {{ $thread->isSolved() ? 'solved' : '' }} _post" data-author-name='{{ json_encode($thread->author->name, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS) }}' data-quote-body='{{ json_encode($thread->resource->body, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS) }}'>
2-
<h1>{{{ $thread->subject }}}</h1>
2+
<h1>
3+
@if ($thread->pinned)
4+
[Pinned]
5+
@endif
6+
7+
{{{ $thread->subject }}}
8+
</h1>
39

410
<span class="markdown">
511
{{ $thread->body }}

0 commit comments

Comments
 (0)
0