mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-09 21:42:57 +00:00
add tags to posts
This commit is contained in:
parent
2f95117389
commit
c77c97be2d
5 changed files with 26 additions and 3 deletions
|
|
@ -46,4 +46,10 @@ class DeletionController extends Controller
|
|||
$tagGroup->delete();
|
||||
return redirect()->route('tags.groups');
|
||||
}
|
||||
|
||||
public function deletePostTag(Post $post, Tag $tag)
|
||||
{
|
||||
$post->tags()->detach($tag);
|
||||
return redirect("/posts/$post->id/edit");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@ namespace App\Livewire\Posts;
|
|||
|
||||
use App\Models\Post;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
|
||||
class Edit extends Component
|
||||
{
|
||||
public Post $post;
|
||||
public Collection $tags;
|
||||
public Collection $selectableTags;
|
||||
public $tags;
|
||||
public $selectableTags;
|
||||
|
||||
#[Validate('exists:tags,id')]
|
||||
public string $tag = '';
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@
|
|||
Feature post
|
||||
</wa-switch>
|
||||
@endif
|
||||
|
||||
<wa-select wire:model.live="tag" label="Add a tag" @error('tag') hint="{{ $message }}" @enderror wire:loading.attr="disabled">
|
||||
@foreach ($selectableTags as $selectableTag)
|
||||
<wa-option value="{{ $selectableTag->id }}" style="color: {{ $selectableTag->tagGroup->color }};">{{ $selectableTag->name }}</wa-option>
|
||||
@endforeach
|
||||
</wa-select>
|
||||
</form>
|
||||
|
||||
<wa-divider></wa-divider>
|
||||
|
|
@ -34,6 +40,13 @@
|
|||
<span>Tags</span>
|
||||
</div>
|
||||
|
||||
@foreach ($tags as $postTag)
|
||||
<div class="wa-split">
|
||||
<span style="color: {{ $postTag->tagGroup->color }};">{{ $postTag->name }}</span>
|
||||
<wa-icon-button name="times" appearance="plain" href="{{ url("/delete/post/$post->id/tag/$postTag->id") }}" wire:navigate></wa-icon-button>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<wa-divider></wa-divider>
|
||||
|
||||
<div class="wa-split">
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@
|
|||
<span>Tags</span>
|
||||
</div>
|
||||
|
||||
@foreach ($post->tags as $tag)
|
||||
<span style="color: {{ $tag->tagGroup->color }};">{{ $tag->name }}</span>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Main content --}}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Route::middleware('auth')->prefix('tags')->group(function () {
|
|||
Route::middleware('auth')->prefix('delete')->controller(DeletionController::class)->group(function () {
|
||||
Route::get('comment/{comment}', 'deleteComment');
|
||||
Route::get('post/{post}', 'deletePost');
|
||||
Route::get('post/{post}/tag/{tag}', 'deletePostTag');
|
||||
Route::get('tag/{tag}', 'deleteTag');
|
||||
Route::get('group/{tagGroup}', 'deleteTagGroup');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue