mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +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();
|
$tagGroup->delete();
|
||||||
return redirect()->route('tags.groups');
|
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\Post;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Edit extends Component
|
class Edit extends Component
|
||||||
{
|
{
|
||||||
public Post $post;
|
public Post $post;
|
||||||
public Collection $tags;
|
public $tags;
|
||||||
public Collection $selectableTags;
|
public $selectableTags;
|
||||||
|
|
||||||
#[Validate('exists:tags,id')]
|
#[Validate('exists:tags,id')]
|
||||||
public string $tag = '';
|
public string $tag = '';
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@
|
||||||
Feature post
|
Feature post
|
||||||
</wa-switch>
|
</wa-switch>
|
||||||
@endif
|
@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>
|
</form>
|
||||||
|
|
||||||
<wa-divider></wa-divider>
|
<wa-divider></wa-divider>
|
||||||
|
|
@ -34,6 +40,13 @@
|
||||||
<span>Tags</span>
|
<span>Tags</span>
|
||||||
</div>
|
</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>
|
<wa-divider></wa-divider>
|
||||||
|
|
||||||
<div class="wa-split">
|
<div class="wa-split">
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@
|
||||||
<span>Tags</span>
|
<span>Tags</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@foreach ($post->tags as $tag)
|
||||||
|
<span style="color: {{ $tag->tagGroup->color }};">{{ $tag->name }}</span>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Main content --}}
|
{{-- Main content --}}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ Route::middleware('auth')->prefix('tags')->group(function () {
|
||||||
Route::middleware('auth')->prefix('delete')->controller(DeletionController::class)->group(function () {
|
Route::middleware('auth')->prefix('delete')->controller(DeletionController::class)->group(function () {
|
||||||
Route::get('comment/{comment}', 'deleteComment');
|
Route::get('comment/{comment}', 'deleteComment');
|
||||||
Route::get('post/{post}', 'deletePost');
|
Route::get('post/{post}', 'deletePost');
|
||||||
|
Route::get('post/{post}/tag/{tag}', 'deletePostTag');
|
||||||
Route::get('tag/{tag}', 'deleteTag');
|
Route::get('tag/{tag}', 'deleteTag');
|
||||||
Route::get('group/{tagGroup}', 'deleteTagGroup');
|
Route::get('group/{tagGroup}', 'deleteTagGroup');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue