mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-27 05:50:51 -05:00
update: livewire
This commit is contained in:
@@ -20,14 +20,17 @@ use Livewire\Component;
|
||||
class BookmarkButton extends Component
|
||||
{
|
||||
public Torrent $torrent;
|
||||
|
||||
public User $user;
|
||||
|
||||
public bool $isBookmarked;
|
||||
|
||||
public int $bookmarksCount;
|
||||
|
||||
final public function store(): void
|
||||
{
|
||||
if ($this->user->bookmarks()->where('torrent_id', '=', $this->torrent->id)->exists()) {
|
||||
$this->dispatchBrowserEvent('error', ['type' => 'error', 'message' => 'Torrent Has Already Been Bookmarked!']);
|
||||
$this->dispatch('error', type: 'error', message: 'Torrent Has Already Been Bookmarked!');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -35,7 +38,7 @@ class BookmarkButton extends Component
|
||||
$this->user->bookmarks()->attach($this->torrent->id);
|
||||
$this->isBookmarked = true;
|
||||
$this->bookmarksCount++;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Bookmarked Successfully!']);
|
||||
$this->dispatch('success', type: 'success', message: 'Torrent Has Been Bookmarked Successfully!');
|
||||
}
|
||||
|
||||
final public function destroy(): void
|
||||
@@ -43,7 +46,7 @@ class BookmarkButton extends Component
|
||||
$this->user->bookmarks()->detach($this->torrent->id);
|
||||
$this->isBookmarked = false;
|
||||
$this->bookmarksCount--;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Unbookmarked Successfully!']);
|
||||
$this->dispatch('success', type: 'success', message: 'Torrent Has Been Unbookmarked Successfully!');
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
|
||||
Reference in New Issue
Block a user