mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-02 16:29:49 -05:00
@@ -111,7 +111,7 @@ class TopicController extends Controller
|
||||
'first_post_user_id' => $user->id,
|
||||
'last_post_user_id' => $user->id,
|
||||
'views' => 0,
|
||||
'pinned' => false,
|
||||
'priority' => 0,
|
||||
'forum_id' => $forum->id,
|
||||
'num_post' => 1,
|
||||
]);
|
||||
@@ -339,10 +339,10 @@ class TopicController extends Controller
|
||||
/**
|
||||
* Pin The Topic.
|
||||
*/
|
||||
public function pin(int $id): \Illuminate\Http\RedirectResponse
|
||||
public function pin(Request $request, int $id): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$topic = Topic::findOrFail($id);
|
||||
$topic->pinned = true;
|
||||
$topic->priority = $request->integer('priority');
|
||||
$topic->save();
|
||||
|
||||
return to_route('topics.show', ['id' => $topic->id])
|
||||
@@ -355,7 +355,7 @@ class TopicController extends Controller
|
||||
public function unpin(int $id): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$topic = Topic::findOrFail($id);
|
||||
$topic->pinned = false;
|
||||
$topic->priority = 0;
|
||||
$topic->save();
|
||||
|
||||
return to_route('topics.show', ['id' => $topic->id])
|
||||
|
||||
@@ -117,7 +117,7 @@ class ForumCategoryTopicSearch extends Component
|
||||
fn ($query) => $query
|
||||
->whereDoesntHave('reads', fn ($query) => $query->whereBelongsTo(auth()->user()))
|
||||
)
|
||||
->orderByDesc('pinned')
|
||||
->orderByDesc('priority')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate(25);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class ForumTopicSearch extends Component
|
||||
fn ($query) => $query
|
||||
->whereDoesntHave('reads', fn ($query) => $query->whereBelongsTo(auth()->user()))
|
||||
)
|
||||
->orderByDesc('pinned')
|
||||
->orderByDesc('priority')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate(25);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string|null $state
|
||||
* @property bool $pinned
|
||||
* @property int $priority
|
||||
* @property bool $approved
|
||||
* @property bool $denied
|
||||
* @property bool $solved
|
||||
@@ -54,13 +54,13 @@ class Topic extends Model
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array{last_post_created_at: 'datetime', pinned: 'bool', approved: 'bool', denied: 'bool', solved: 'bool', invalid: 'bool', bug: 'bool', suggestion: 'bool', implemented: 'bool'}
|
||||
* @return array{last_post_created_at: 'datetime', priority: 'integer', approved: 'bool', denied: 'bool', solved: 'bool', invalid: 'bool', bug: 'bool', suggestion: 'bool', implemented: 'bool'}
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'last_post_created_at' => 'datetime',
|
||||
'pinned' => 'bool',
|
||||
'priority' => 'integer',
|
||||
'approved' => 'bool',
|
||||
'denied' => 'bool',
|
||||
'solved' => 'bool',
|
||||
|
||||
@@ -36,7 +36,7 @@ class TopicFactory extends Factory
|
||||
return [
|
||||
'name' => $this->faker->name(),
|
||||
'state' => $this->faker->word(),
|
||||
'pinned' => $this->faker->boolean(),
|
||||
'priority' => $this->faker->randomNumber(),
|
||||
'approved' => $this->faker->boolean(),
|
||||
'denied' => $this->faker->boolean(),
|
||||
'solved' => $this->faker->boolean(),
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('topics', function (Blueprint $table): void {
|
||||
$table->unsignedTinyInteger('pinned')->change();
|
||||
$table->renameColumn('pinned', 'priority');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -82,9 +82,9 @@
|
||||
</article>
|
||||
</header>
|
||||
<figure class="topic-listing__figure">
|
||||
@if ($topic->pinned || $topic->state === 'close')
|
||||
@if ($topic->priority || $topic->state === 'close')
|
||||
<span class="topic-listing__icon">
|
||||
@if ($topic->pinned)
|
||||
@if ($topic->priority)
|
||||
<abbr title="{{ __('common.sticked') }}">
|
||||
<i class="{{ config('other.font-awesome') }} fa-thumbtack"></i>
|
||||
</abbr>
|
||||
|
||||
@@ -182,37 +182,6 @@
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
@if (! $topic->pinned)
|
||||
<form
|
||||
class="form"
|
||||
action="{{ route('topics.pin', ['id' => $topic->id]) }}"
|
||||
method="POST"
|
||||
>
|
||||
@csrf
|
||||
<p class="form__group form__group--horizontal">
|
||||
<button
|
||||
class="form__button form__button--filled form__button--centered"
|
||||
>
|
||||
{{ __('forum.pin') }}
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
@else
|
||||
<form
|
||||
class="form"
|
||||
action="{{ route('topics.unpin', ['id' => $topic->id]) }}"
|
||||
method="POST"
|
||||
>
|
||||
@csrf
|
||||
<p class="form__group form__group--horizontal">
|
||||
<button
|
||||
class="form__button form__button--filled form__button--centered"
|
||||
>
|
||||
{{ __('forum.unpin') }}
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
@@ -321,5 +290,44 @@
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panelV2">
|
||||
<h2 class="panel__heading">Edit Topic Priority</h2>
|
||||
<div class="panel__body">
|
||||
<form
|
||||
class="form"
|
||||
action="{{ route('topics.pin', ['id' => $topic->id]) }}"
|
||||
method="POST"
|
||||
>
|
||||
@csrf
|
||||
<p class="form__group form__group--horizontal">
|
||||
<input
|
||||
type="text"
|
||||
name="priority"
|
||||
id="priority"
|
||||
class="form__text"
|
||||
inputmode="numeric"
|
||||
pattern="[0-9]*"
|
||||
value="{{ $topic->priority }}"
|
||||
/>
|
||||
<label class="form__label form__label--floating" for="season_number">
|
||||
Priority
|
||||
</label>
|
||||
</p>
|
||||
<p class="form__group">
|
||||
<button class="form__button form__button--filled form__button--centered">
|
||||
{{ __('forum.pin') }}
|
||||
</button>
|
||||
@if ($topic->priority)
|
||||
<button
|
||||
class="form__button form__button--filled form__button--centered"
|
||||
formaction="{{ route('topics.unpin', ['id' => $topic->id]) }}"
|
||||
>
|
||||
{{ __('forum.unpin') }}
|
||||
</button>
|
||||
@endif
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user